Tell us what’s happening:
I had solved this Algorithm before the new lessons came out earlier this summer. I was redoing some old algorithms for good measure and I’m having trouble passing this again. I don’t understand why it passes only 3 of the 4 tests. It seems like it should be all or nothing.
Thoughts?
Your code so far
function largestOfFour(arr) {
let largestArr = [];
for (var i=0; i<arr.length; i++)
{
let largestNum=0;
for (var j=0; j<arr.length; j++)
{
if(largestNum<arr[i][j])
{
largestNum=arr[i][j];
}
}
largestArr.push(largestNum);
}
return largestArr;
}
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 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays