HELP ME PLEASE ! πŸ˜… πŸ˜‰

Can anyone tell me whats the problem in this code??

  **Your code so far**

function largestOfFour(arr) {
let resultArray = 0;
let answer = [];
for(let i=0; i < arr.length; i++){
  for(let j=0; j < arr[i].length; j++){
    if(resultArray < arr[i][j]){
      resultArray = arr[i][j];
    }
  }
   answer.push(resultArray);
}
return answer;
}

console.log(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36.

Challenge: Return Largest Numbers in Arrays

Link to the challenge:

Hello there,

Have a look at the last test case:

largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])

It makes the issue most clear.

Hint:

You are currently testing for the largest out of all of the arrays, as opposed to testing for the largest within each array.

Hint 2:

Think about when you are setting the resultArray variable…

Hint 3:

Why have you chosen 0 to be the value for resultArray?

Hope this helps

I got the problem in its working . :innocent:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.