Skip to content

Instantly share code, notes, and snippets.

@yitonghe00
Last active April 17, 2020 05:35
Show Gist options
  • Save yitonghe00/27359e8d6c6ee5c7996787d04a56cfde to your computer and use it in GitHub Desktop.
Save yitonghe00/27359e8d6c6ee5c7996787d04a56cfde to your computer and use it in GitHub Desktop.
// Your code here.
const loop = (init, test, next, body) => {
for (let i = init; test(i); i = next(i)) {
body(i);
}
};
loop(3, n => n > 0, n => n - 1, console.log);
// → 3
// → 2
// → 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment