how to run foreach in es6 only three loops code example
Example 1: loop through arrays in es6
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"
Example 2: javascript foreach call specific value in array
run.addEventListener("click", function () {
people.forEach((element) => console.log(element.firstname));
}); // select a specific string in array