Tell us what’s happening:
I want the largest value from each of the subarray’s and push that values into a brand new array but I don’t know what’s wrong with this code
Your code so far
function largestOfFour(arr) {
let newarr = []
for(let i=0; i<arr.lentgh; 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/87.0.4280.88 Safari/537.36
.
Challenge: Return Largest Numbers in Arrays
Link to the challenge: