get element from each item in array javascript code example
Example 1: forEach index
const array1 = ['a', 'b', 'c'];
array1.forEach((element, index) => console.log(element, index));
Example 2: how to use the foreach method in javascript
groceries.forEach(groceryItem => console.log(groceryItem));