Skip to content

Instantly share code, notes, and snippets.

@jbmilgrom
Last active September 22, 2019 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbmilgrom/f9d9a32cb65374d3c6aa061a13c799d4 to your computer and use it in GitHub Desktop.
Save jbmilgrom/f9d9a32cb65374d3c6aa061a13c799d4 to your computer and use it in GitHub Desktop.
"functional" semantics with looping construct
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