Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"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
You can’t perform that action at this time.