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

…衆ロ難τιáo~ 提交于 2019-12-10 01:52:27

问题


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


回答1:


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);


来源:https://stackoverflow.com/questions/14693568/jquery-get-maximum-value-in-an-array-of-numbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!