create a loop that runs through each item in an array
Create a loop that runs through each item in the "fruits" array.
var fruits = ['Apple', 'Banana', 'Orange']
for(x of fruits){
console.log(x);
}
create a loop that runs through each item in an array
Create a loop that runs through each item in the "fruits" array.
var fruits = ['Apple', 'Banana', 'Orange']
for(x of fruits){
console.log(x);
}
Iterate Through All an Array’s Items Using For Loops
function filteredArray(arr, elem) {
let newArr = [];
// change code below this line
for (let i = 0; i < arr.length; i++) {
if (arr[i].indexOf(elem) == -1) {
//Checks every parameter for the element and if is NOT there continues the code
newArr.push(arr[i]); //Inserts the element of the array in the new filtered array
}
}
// change code above this line
return newArr;
}
// change code here to test different cases:
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
Iterate Through an Array with a For Loop
var arr = [10, 9, 8, 7, 6];
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
Iterate Through an Array with a For Loop
var arr = [10, 9, 8, 7, 6];
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us