Print the max of [3, 7, 2, 9, 1].
Ready — edit the code above and click Run.
const arr = [3, 7, 2, 9, 1];
console.log(Math.max(...arr));
Try solving on your own first, then reveal the official answer.
Spread operator with Math.max is concise. For large arrays, use a loop to avoid stack limits.