Last active
September 22, 2019 21:35
-
-
Save jbmilgrom/f9d9a32cb65374d3c6aa061a13c799d4 to your computer and use it in GitHub Desktop.
"functional" semantics with looping construct
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 add10 = n => { | |
let sum = n; | |
for (let i = 0; i < 10; i++) { | |
sum = sum + 1; | |
} | |
return sum; | |
}; | |
add10(2); // => 12 | |
add10(1); // => 11 | |
add10(0); // => 10 | |
add10(-1); // => 9 | |
add10(-2); // => 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment