how to iterate list in java using foreach loop in javascript code example
Example 1: foreach loop javascript
const numList = [1, 2, 3];
numList.forEach((number) => {
console.log(number);
});
Example 2: javascript foreach
const colors = ['blue', 'green', 'white'];
function iterate(item) {
console.log(item);
}
colors.forEach(iterate);
// logs "blue"
// logs "green"
// logs "white"