max and min value javascript code example
Example 1: javascript minimum number in array
const min = arr => Math.min(...arr);
Example 2: finding the smallest number in an array javascript
var arr = [5,1,9,5,7];
var smallest = arr[0];
for(var i=1; i<arr.length; i++){
if(arr[i] < smallest){
smallest = arr[i];
}
}
console.log(smallest);