Profile Picture

Prajwal Dhungana

Go Back

How to Find the Largest Number in an Array in JavaScript

Published on Aug 28, 2024

Finding the Largest Number in an Array in JavaScript

To find the largest number in an array, you can use the Math.max function along with the spread operator. This method is concise and efficient.

Example Code

JavaScript Playground
Loading...
Console

In this code:

  • We define an array called numbers.
  • We use Math.max with the spread operator (...) to find the largest number.
  • The result is stored in the variable result.

Hash Tags:

#JavaScript
#Arrays