Categories
JavaScript Answers

How to get max and min value from array in JavaScript?

Spread the love

Sometimes, we want to get max and min value from array in JavaScript.

In this article, we’ll look at how to get max and min value from array in JavaScript.

How to get max and min value from array in JavaScript?

To get max and min value from array in JavaScript, we use some math methods.

For instance, we write

const array = [1, 3, 2];
const max = Math.max(...array);
const min = Math.min(...array);

to spread the entries of array as arguments of Math.max and Math.min.

max returns the max value in the list of arguments.

min returns the max value in the list of arguments.

Conclusion

To get max and min value from array in JavaScript, we use some math methods.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.