Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find max value in array javascript

// find maximum value of array in javascript
// array reduce method
const arr = [49,2,71,5,38,96];
const max = arr.reduce((a, b) => Math.max(a, b));
console.log(max); // 96

// math.max apply method
const max_ = Math.max.apply(null, arr);
console.log(max_); // 96

// or math.max spread operator method
const max__ = Math.max(...arr);
console.log(max__); // 96
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #max #array #javascript
ADD COMMENT
Topic
Name
8+1 =