0 points

Function to find maximum value in javascript array


dashboard

Sun Jan 05 2020 19:35:54 GMT+0000 (UTC)

Posted by @bezequi #javascript #webdev #javascript #arrays #math

const arrMax = arr => Math.max(...arr);
// arrMax([20, 10, 5, 10]) -> 20
content_copy Copy

Math is a built in object in JavaScript that contains certain methods useful for performing mathematical tasks. One of these methods is max(). Math.max() returns the largest of any set of given numbers.

https://codeburst.io/javascript-arrays-finding-the-minimum-maximum-sum-average-values-f02f1b0ce332