Alternative to .push() for creating a new array?

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

1 Like