Created
March 13, 2022 16:52
-
-
Save AitorAlejandro/56163326a26b44ff629fadcb2bd288fc to your computer and use it in GitHub Desktop.
Get the max prop value from an object array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const objectList = [ | |
{ value: 1 }, | |
{ value: 2 }, | |
{ value: 3 }, | |
{ value: 4 }, | |
{ value: 5 } | |
]; | |
const maxValue = Math.max(...objectList.map(x => x.value)); | |
// maxValue -> 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment