Last active
December 8, 2020 10:00
-
-
Save pertrai1/303b5149d122c15bdb6b9305608b71c3 to your computer and use it in GitHub Desktop.
collectionSum
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 collectionSum = (collection) => { | |
const iterator = collection.iterator(); | |
let eachIteration; | |
let sum = 0; | |
while ((eachIteration = iterator(), !eachIteration.done)) { | |
sum += eachIteration.value; | |
} | |
return sum; | |
} | |
collectionSum(stack) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment