Iterate Through All An Arrays Items Using For Loops

[Solved] Iterate Through All An Arrays Items Using For Loops | Perl - Code Explorer | yomemimo.com
Question : Iterate Through All an Array's Items Using For Loops

Answered by : ralph-dizon

function filteredArray(arr, elem) { let newArr = []; // Only change code below this line for (let i = 0; i < arr.length; i++) { if (arr[i].indexOf(elem) === -1) { newArr.push(arr[i]); } } // Only change code above this line return newArr;
}
console.log(filteredArray([["amy", "beth", "sam"], ["dave", "sean", "peter"]], "peter"));

Source : | Last Update : Wed, 23 Mar 22

Question : Iterate over all the items in array of arrays

Answered by : weary-whale-694eepw13r55

for( var i = 0, len_i = json.length; i < len_i; i++ ) { for( var j = 0, len_j = json[ i ].length; j < len_j; j++ ) { // do something with json[ i ][ j ]; (the value in the inner Array) }
}

Source : https://stackoverflow.com/questions/4771434/how-to-select-from-an-array-of-arrays | Last Update : Wed, 06 Oct 21

Answers related to iterate through all an arrays items using for loops

Code Explorer Popular Question For Perl