Tell us what’s happening:
I was stuck so I looked at the solution and I changed my var modArr = to modArr = [0,0,0,0] and I wanted to use push(i) to push the largest integer to my modArr instead I did the solution way.
Was my way possible?
Your code so far
function largestOfFour(arr) {
// You can do this!
var modArr = [0,0,0,0];
for(var i = 0; i<arr.length; i++){
for(var j = 0; j<arr[i].length; j++){
if(arr[i][j] > modArr[i]){
modArr[i] = arr[i][j];
}
}
}
return modArr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/return-largest-numbers-in-arrays