Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

forEach In a forEach method, we pass each food type within that iteration into the callback. A for loop needs you to access the array using a temporary i variable.

foodArray.forEach((food) => {
  console.log(food);
  food.ingredients.forEach((ingredient) => {
    console.log(ingredient);
  });
});
Source by alligator.io #
 
PREVIOUS NEXT
Tagged: #forEach #In #forEach #pass #food #type #iteration #A #loop #access #array #temporary
ADD COMMENT
Topic
Name
6+5 =