My browser hung when i ran the code,how is this an infinite loop.
Your code so far
function largestOfFour(arr) {
// You can do this!
var max = 0;
var largest;
for(let i = 0;i<arr.length;i++){
for(let j = 0;j<arr[i].length;j++){
if(arr[i][j]>max){
max = arr[i][j];
largest = max;
}
}
arr.push(largest);
}
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays