find maximum value in array jas code example
Example 1: 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 2: find max and min value in array javascript
var numbers = [1, 2, 3, 4];
Math.max(...numbers) // 4
Math.min(...numbers) // 1