forEach()
method
ES5
Executes a provided function once for each array element. Does not return a value.
Syntax
array.forEach(callback(element, index, array))
Example
javascript
const fruits = ['apple', 'banana', 'cherry'];
fruits.forEach((fruit, index) => {
console.log(`${index + 1}. ${fruit}`);
});
// 1. apple
// 2. banana
// 3. cherry