Last active
April 6, 2017 12:49
-
-
Save no23reason/0425072ff7aa02e63f1f22e2cdc6e72a to your computer and use it in GitHub Desktop.
For-loop tax Medium code snippets
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 sum = (array) => { | |
let result = 0; | |
for (let i = 0; i < array.length; i++) { | |
result += array[i]; | |
} | |
return result; | |
} | |
const numbers = [5, 25, 8, 18]; | |
console.log(sum(numbers)); // logs 56 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment