You are viewing a single comment's thread. Return to all comments →
JavaScript solution:
function simpleArraySum(ar) { var count = 0; for (var i = 0; i < ar.length; i++) { count += ar[i]; } return count; }
Then I made it a one-liner using reduce:
function simpleArraySum(ar) { return ar.reduce((a, b) => a + b) }
Seems like cookies are disabled on this browser, please enable them to open this website
Simple Array Sum
You are viewing a single comment's thread. Return to all comments →
JavaScript solution:
Then I made it a one-liner using reduce: