Tell us what’s happening:
I checked this in CodePen and it returns the right answers for all of the arrays tested but for some reason it doesn’t pass. I can’t seem to figure out what I’m missing. Thanks as always.
Your code so far
function largestOfFour(arr) {
let newArr = [];
for (i = 0; i < arr.length; i++) {
newArr.push(Math.max(...arr[i]));
}
return newArr;
}
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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36
.
Challenge: Return Largest Numbers in Arrays
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays