js get min of array code example
Example 1: get highest value from array javascript
var arr =[1,10,3]
var min = Math.min.apply(null, arr),
max = Math.max.apply(null, arr);
var arr = [{a: 1},{a: 10},{a: 3}]
var values = arr.map(val => val.a);
var max = Math.max.apply(null, values);
console.log(max)
Example 2: Find the maximum number of an array js
var arr = [1, 2, 3];
var max = arr.reduce(function(a, b) {
return Math.max(a, b);
});
Example 3: min array javascript
const nums = [1, 2, 3]
Math.min(...nums)
Math.max(...nums)
Example 4: javascript index of min value in array
arr = [11, 10, 10];
var index = arr.indexOf(Math.max(...arr));
Example 5: javascript find the min in array of numbers
let arrayOfIntegers = [9, 4, 5, 6, 3];
let min = Math.min(...arrayOfIntegers);
Example 6: javascript math min array
const nums = [1, 2, 3]Math.min(...nums)