I am trying to write a conditional that will find if a recipe is for vegetarians. If is not for vegetarians, I want to console log the recipe array along with a message (non-vegetarian).
I tried couple of things, two for loops, and now I am trying with a forEach and includes. the problem is that something is wrong with my logic, is not printing the non-vegetarian message, and also, I am printing the recipes 3 times. This was the only thing I could think of, since I have to have a loop for the vegetarian items as well.
I have a bin here. is a bit of a mess.
var cookbook = [noodlesWithChicken, bakedPotatoWithBroccoli, hamPineapplePitaPizza, shrimpOliveSalad, chocolateBananaSundae];
var noodlesWithChicken = ["noodles", "chicken", "carrots", "cucumber", "peanut butter", "soy sauce" ];
var bakedPotatoWithBroccoli = ["russet potatos", "broccolli", "butter", "salt", "sour cream"];
var hamPineapplePitaPizza = ["pitas", "mozzarella", "pineaples", "ham"];
var shrimpOliveSalad = ["shrimp", "lettuce", "tomatoes", "artichoke", "black olives", "mayo", "chili sauce"];
var chocolateBananaSundae = ["bananas", "vanilla ice cream", "chocolate sauce", "shredded coconut"];
var vegetarians = ["chicken", "ham", "shrimp"];
var veganItems = ["chicken", "ham", "shrimp", "mozzarella", "sour cream", "mayo", "vanilla ice cream"];
cookbook.forEach(function(item){
for(var i = 0; i < vegetarians.length; i++){
if(cookbook.includes(vegetarians[i])){
console.log(item + " (non-vegetarian)");
} else {
console.log(item);
}
}
});