Created
May 23, 2020 05:31
-
-
Save hebertcisco/259d481c5a4bd770efb41d29bc9ac96e to your computer and use it in GitHub Desktop.
The reduce() method performs a reducing function (download for you) for each element of the matrix, resulting in a single return value.
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 githubStars = [ | |
{ | |
userID: "tecnobert", | |
userStars: 88, | |
}, | |
{ | |
userID: "philipwalton", | |
userStars: 36, | |
}, | |
{ | |
userID: "cytopia", | |
userStars: 370, | |
}, | |
]; | |
const totalStars = githubStars.reduce((sum, stars) => { | |
return sum + stars.userStars; | |
}, 0); | |
console.log(totalStars); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment