var items = ["milk", "bread", "sugar"];
function checkForProduct(item) {
if (items.indexOf(item) === -1) {
console.log("item does not exist");
} else {
console.log("item is in your list");
}
}
checkForProduct("socks"); //item does not exist
checkForProduct("milk"); //item is in your list
0 Comments