Tell us what’s happening:
My code for this challenge returns the correct values, but the commas appear one digit off from what the “expected” solution is supposed to be, which is frustrating as it means my code is not passing the challenge. I tested the code in repl.it and it appears correctly. Below is my code - am I actually in error here, or is this just an issue with how the challenge is testing my code? Thank you.
Link to the challenge:
https://www.freecodecamp.org/challenges/return-largest-numbers-in-arrays
My code:
var newArray= [0, 0, 0, 0];
function largestOfFour(arr) {
for (i = 0; i < 4; i++) {
console.log ("Analyzing array number " + i);
for (j = 0; j <4; j++) {
console.log ("Analyzing subarray number " + j);
if (arr[i][j] > newArray[i])
{
console.log("Old highest value in array number " + [i] + " is " + newArray[i]);
console.log("New highest value in array number " + [i] + " is " + arr[i][j]);
newArray[i] = arr[i][j];
}
}
}
return newArray;
}
largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]);