javascript for over a code example
Example 1: javascipr for of
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
// expected output: "a"
// expected output: "b"
// expected output: "c"
Example 2: use these instead of a for loop javascript
const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) { // expressions that return 'true' are retained return elem % 2 == 0;});