get max value from array
just a version to get the max value from an array
This commit is contained in:
committed by
GitHub
parent
271130ef08
commit
699f291edc
8
snippets/get-max-value-from-array.md
Normal file
8
snippets/get-max-value-from-array.md
Normal file
@ -0,0 +1,8 @@
|
||||
### Get max value from array
|
||||
|
||||
Passing an array, it executes the Math.max method using the spread operator to fill its variadic arguments and returns the maximum value found in the array.
|
||||
|
||||
```js
|
||||
const getMaxValue = arr => Math.max(...arr);
|
||||
// getMaxValue([10, 1, 5]) -> 10
|
||||
```
|
||||
Reference in New Issue
Block a user