how to use the foreach method in javascript

JavaScript
const fruits = ['mango', 'papaya', 'pineapple', 'apple'];

// Iterate over fruits below

// Normal way
fruits.forEach(function(fruit){
  console.log('I want to eat a ' + fruit)
});const array1 = ['a', 'b', 'c'];

array1.forEach(element => console.log(element));var colors = ["red", "blue", "green"];
colors.forEach(function(color) {
    console.log(color);
});var colors = ['red', 'blue', 'green'];

colors.forEach(function(color) {
  console.log(color);
});groceries.forEach(groceryItem => console.log(groceryItem));
Source

Also in JavaScript: