A little trouble here. Been working on these lines of code to receive string parameters from the checkBaggage() function which will then use the if/else statement to check for certain words e.g "Knife", "Gun" in the user input stored at variable baggage.
However, instead of writing those check words directly into the baggage.includes() method,
i.e
if (baggage.includes('knife') || baggage.includes('gun')) {
console.log('You are NOT allowed on board');
};
I want it to loop through the array single to check for the words and then determine if they are present or not.
I need help! Thank you.
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');