I'm attempting to extract the largest value from each subarray and store those values in a new array, but for some reason, the output is always an empty array. I can't seem to figure out what's wrong with my code.
function findLargestValues(arr) {
let newArr = []
for(let i=0; i<arr.lentgh; i++){
newArr.push(Math.max(...arr[i]))
}
return newArr;
}
let largestValues = findLargestValues([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
console.log(largestValues);