Tell us what’s happening:
I can’t understand what is happening here.
function greaterThanTen(arr) { //this takes the array bellow 2, 12, 8, 14, 80, 0, 1 and stores it into the arr?
let newArr = []; //this creates a let called newArr and assign a new variable to it?
for (let i = 0; i < arr.length; i++) { //this set I to 0 as a starting point until the arr.lenght the length thus of the array bellow is reaches and increaments it with 1+ each time so 2 , 3 ,4 5??
if (arr[i] > 10) { //this is array and the coordinate of I is bigger then 10
newArr.push(arr[i]); //this pushes the new array through the loop??
}
}
return newArr;
}
greaterThanTen([2, 12, 8, 14, 80, 0, 1]);
// returns [12, 14, 80]
Then the instructions
what is elem?
element? is it an array? a string? a boolean? what is elem?
The more I try to read it the more confused.
Your code so far
function filteredArray(arr, elem) {
let newArr = [];
// Only change code below this line
for(let i = 0; i <arr.lenght; i++)
// Only change code above this line
return newArr;
}
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36.
Challenge: Iterate Through All an Array’s Items Using For Loops
Link to the challenge: