for of string code example
Example 1: javascript loop through string
for (var i = 0; i < str.length; i++) {
console.log(str.charAt(i));
}
Example 2: javascipr for of
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
Example 3: use these instead of a for loop javascript
const array = [1, 2, 3];array.forEach(function(elem, index, array) { array[index] = elem * 2;});console.log(array);
Example 4: use these instead of a for loop javascript
const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) {