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.

74

foodArray.forEach((food) => {
  console.log(food);
  food.ingredients.forEach((ingredient) => {
    console.log(ingredient);
  });
});

Comments

Submit
0 Comments