Return Largest Numbers in Arrays - not passing

Tell us what’s happening:

I don’t understand why this code is not passing, in it works fine and returns an array of largest numbers from each sub-array.

Your code so far

function largestOfFour(arr) {
  let tempArr = [];
  for (let i=0; i<arr.length; i++) {
    let count = 0;
    for (let j=0; j<arr[i].length; j++) if (arr[i][j] > count) count = arr[i][j];
  return tempArr;

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_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Link to the challenge:

it would be really useful if you would say what errors you get, otherwise it is just guessing.

break this down, too many things on the same line. this is giving one error in the freecodecamp editor.

second… what happen when the largest number is smaller then 0?

Yes, you’re right about the negative numbers, I didn’t account for that, I will refactor. But with all positive numbers I don’t get any errors when I run it in, but freeCodeCamp editor gives me a TypeError: unknown: Cannot read property '0' of undefined error.

Oh, I see what you mean. That’s weird, I use one-liners all the time, never had a problem with it.

Just had to change the count assignment line, everything works with the negative numbers, too now:
let count = arr[i][0];