MCPcopy Create free account
hub / github.com/braziljs/eloquente-javascript / loop

Function loop

code/solutions/05_2_your_own_loop.js:1–5  ·  view source on GitHub ↗
(start, test, update, body)

Source from the content-addressed store, hash-verified

1function loop(start, test, update, body) {
2 for (let value = start; test(value); value = update(value)) {
3 body(value);
4 }
5}
6
7loop(3, n => n > 0, n => n - 1, console.log);
8// → 3

Callers 1

Calls 1

updateFunction · 0.85

Tested by

no test coverage detected