Skip to content

Instantly share code, notes, and snippets.

@pertrai1
Last active December 8, 2020 10:00
Show Gist options
  • Save pertrai1/303b5149d122c15bdb6b9305608b71c3 to your computer and use it in GitHub Desktop.
Save pertrai1/303b5149d122c15bdb6b9305608b71c3 to your computer and use it in GitHub Desktop.
collectionSum
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