forEach is a terminal javascript functional operation that will loop over each element:
The syntax is important, the function is called forEach with a uppercase E, otherwise you get a Unknown function call
['blue', 'green', 'yellow'].forEach((color, index) => console.log(`${index} - ${color}`));
With map
['a','b','c']
.map(letter => letter.toUpperCase())
.forEach(letter => console.log(letter));
In a foreach loop, you should use the return function to stop the processing and not continue.