Tell us what’s happening:
Hello! I’ve tried a few approaches to solving this problem and for some reason the simplest version of code that I could come up with that uses loops still isn’t providing the correct answer. Can someone please help me identify what I might be doing wrong? Thanks!
Your code so far
function largestOfAll(arrayOfArrays) {
let results = []
for (let i = 0; i < arrayOfArrays.length; i++) {
let largestNumber = arrayOfArrays[i][0];
for (let j = 1; j < arrayOfArrays[i].length; j++) {
if (arrayOfArrays[i][j] > largestNumber) {
largestNumber = arrayOfArrays[i][j];
}
results.push(largestNumber);
}
return results;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Challenge Information:
Build the Largest Number Finder - Build the Largest Number Finder