Skip to content

Get minimum and maximum values of array in JavaScript

22. April 2013

Basically, a very simple JavaScript functionality. But as I searched it the third time, within a short time period…I have to store it here:

Calculate min & max of an array:

Math.max.apply(Math, my_array)
Math.min.apply(Math, my_array)

I did not found it out by myself, I took it from this discussion!

You could also use:

Math.max(my_array)
Math.min(my_array)

…but that doesn’t always work, without knowing why 😉

 

Advertisements

From → tutorial

One Comment
  1. Chris permalink

    Thank you, had this very problem today.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: