Function to find maximum value in javascript array


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

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

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

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.