const array1 = ['a', 'b', 'c']; array1.forEach(element => console.log(element));
const array1 = ['a', 'b', 'c']; array1.forEach((element) => { console.log(element) }); // expected output: "a" // expected output: "b" // expected output: "c"
let array = ['Item 1', 'Item 2', 'Item 3']; array.forEach(item => { console.log(item); // Logs each 'Item #' });
var sandwiches = [ 'tuna', 'ham', 'turkey', 'pb&j' ]; sandwiches.forEach(function (sandwich, index) { console.log(index); console.log(sandwich); }); // returns 0, "tuna", 1, "ham", 2, "turkey", 3, "pb&j"
arr.forEach(function callback(currentValue [, index [, array]]) { // Ihr Iterator }[, thisArg]);