javascript foreach with a array of items code example
Example 1: foreach javascript
Used to execute the same code on every element in an array
Does not change the array
Returns undefined
Example 2: javascript foreach syntax
const marks = [12, 17, 14];
let sum = 0;
marks.forEach(mark => {
sum += mark;
});