Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

386
Views
¿Cómo hago un bucle en una matriz para buscar palabras en una cadena? JavaScript

Un pequeño problema aquí. He estado trabajando en estas líneas de código para recibir parámetros de cadena de la función checkBaggage() que luego usará la declaración if/else para verificar ciertas palabras, por ejemplo "Knife", "Gun" en la entrada del usuario almacenada en baggage variable.

Sin embargo, en lugar de escribir esas palabras de verificación directamente en el método baggage.includes() ,

es decir

 if (baggage.includes('knife') || baggage.includes('gun')) { console.log('You are NOT allowed on board'); };

Quiero que recorra la matriz single para verificar las palabras y luego determinar si están presentes o no.

¡Necesito ayuda! Gracias.

 const checkBaggage = function (items) { const baggage = items.toLowerCase(); const notAllowed = ['knife', 'gun', 'camera']; let single = []; for (const nota of notAllowed) { single.push([nota]); } // console.log(single) if (baggage.includes()) { console.log('You are NOT allowed on board'); } else { console.log('Welcome aboard!'); } }; checkBaggage('I have a laptop, some Food and a pocket Knife'); checkBaggage('Socks and camera'); checkBaggage('Socks and Food'); checkBaggage('Got some snacks and a gun for protection');
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!