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