when to use foreach code example Example: how to use the foreach method in javascript groceries.forEach(groceryItem => console.log(groceryItem));