0

Write a JavaScript program to find maximum and minimum value in an array

JavaScript

9th May 2018, 5:25 PM
Ankita Samal
Ankita Samal - avatar
6 Respuestas
+ 6
max=Math.max(...arr); min=Math.min(...arr); or.. max=Math.max.apply(null,arr); min=Math.min.apply(null,arr); several other ways
9th May 2018, 5:39 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 4
I'll recommend you guys should learn ecmascript 6, it will save you the stress of typing shit like Max.prototype.aplly()..bla bla bla
9th May 2018, 6:04 PM
Dlite
Dlite - avatar
+ 4
use the right set of words D'lite!
10th May 2018, 1:01 AM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar
+ 2
Mind To Machine Forgive my words.. But let's tell ourselves the truth! ES6 is a language that supports the notion: Write less, do same,period
26th May 2018, 6:17 PM
Nagato
Nagato - avatar
+ 1
For max: var arr=[1,2,3]; var mxval=0; for(var i=0; i<arr.length; i++){ if(arr[i] >mxval){ mxval= arr[i]; console.log(mxval);} } //same reverse for min value
9th May 2018, 5:55 PM
Laxman Rana
Laxman Rana - avatar