{}
run-icon
main.js
function* fibonacci() { let a = 0, b = 1; while (true) { yield a; [a, b] = [b, a + b]; } } const gen = fibonacci(); let result = gen.next(); while (result.value < 100) { process.stdout.write(result.value + " "); result = gen.next(); }
Output