Easy javascript

Find maximum in array

Problem

Print the max of [3, 7, 2, 9, 1].

Hints
  • Math.max(...arr)

Your practice code

Ready — edit the code above and click Run.

Solution

const arr = [3, 7, 2, 9, 1];
console.log(Math.max(...arr));

Try solving on your own first, then reveal the official answer.

Explanation

Spread operator with Math.max is concise. For large arrays, use a loop to avoid stack limits.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details