Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to find minimum value in array using JavaScript

by
Category:javascript
javascript
How to find minimum value in array using JavaScript

I have been using some JavaScript techniques in the past to find the minimum number in an array. I recently stumbled upon a real fast and simple solution to find the min number in an array and thought of sharing it with all of you. Let me know what do you think of this method.

var array =  [ "17", "15", "21", "5", "25", "10", "20" ];
var minvalue  = Math.min.apply(null, array);
console.log(minvalue);			

Output

5

Another Example

var array =  [10,3,2,5,9,20];
var minvalue  = Math.min.apply(null, array);
console.log(minvalue);	

Output

2

How to find maximum value in array using JavaScript

How to convert comma separated string to array using JavaScript


0 Comments


Html code work in comment box


Related Post