function largestOfFour(arr) {
let max= [];
arr.forEach(num => max.push(Math.max(...num)))
return max;
}
instead of declaring max = []
and pushing every value into it is there another way I can do it all in one line?
function largestOfFour(arr) {
let max= [];
arr.forEach(num => max.push(Math.max(...num)))
return max;
}
instead of declaring max = []
and pushing every value into it is there another way I can do it all in one line?
Array has a map method just for that kind of thing