Files
30-seconds-of-code/snippets/max.md
Angelos Chalaris cf2fd804b8 Fixed max for good
2017-12-29 15:15:40 +02:00

270 B

max

Returns the maximum value out of two or more numbers/arrays.

Use Math.max() combined with the spread operator (...) to get the maximum value in the array.

const max = (...arr) => Math.max(...[].concat(...arr));
max([10, 1, 5]); // 10