Last active
January 17, 2019 19:34
-
-
Save giolvani/5ad07ad8ff12d91ad8af2942673e6326 to your computer and use it in GitHub Desktop.
Array helpers
This file contains 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
// order by asc | |
itens.sort((a, b) => a.property - b.property); | |
// order by desc | |
itens.sort((a, b) => b.property - a.property); |
This file contains 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 sum = itens.map(item => item.property).reduce((prev, next) => prev + next, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment