Skip to content

Instantly share code, notes, and snippets.

@homam

homam/oneToTen-sum.js

Last active May 18, 2019
Embed
What would you like to do?
oneToTen.reduce(function(acc, a) {
return acc + a;
}, 0)
let sum = function(arr) {
let acc = 0 // the accumulated sum
for(var i = 0; i < arr.length; i++) {
let a = arr[i] // ith item in the array
acc += a
}
return acc
}
sum(oneToTen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.