javascript array for each within code example
Example 1: javascript foreach syntax
const marks = [12, 17, 14];
let sum = 0;
marks.forEach(mark => {
sum += mark;
});
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