Tell us what’s happening:
hii there…i cannot pass the test
largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]) should return [25, 48, 21, -3]. pls help
Your code so far
function largestOfFour(arr) {
// You can do this!
let biggestarray=[0,0,0,0];
for(let i=0;i<arr.length;i++)
{
for(let j=0;j<arr[i].length;j++)
{
if(arr[i][j]>biggestarray[i])
{
biggestarray[i]=arr[i][j];
}
}
}
console.log(biggestarray);
return biggestarray;
}
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; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays