Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery: Get Maximum value in An Array of Numbers [closed]

With jquery, how can I get the maximum value in an array or numbers?

Example:

var myArray = [1,4,7,3,12,0]

Expected Output:-

maximum value = 12

like image 908
Julio Fong Avatar asked Feb 04 '13 18:02

Julio Fong


1 Answers

if by highest number you mean max value you don't need jQuery. You could do:

var myArray = [9,4,2,93,6,2,4,61,1];
var maxValueInArray = Math.max.apply(Math, myArray);
like image 117
DiverseAndRemote.com Avatar answered Nov 15 '22 18:11

DiverseAndRemote.com