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');