Created
February 20, 2019 08:36
-
-
Save RosanaRufer/b0373f5a4c298ee16f87fd4fdc8b8367 to your computer and use it in GitHub Desktop.
A JavaScript Iterator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *dameNumeroFibonacci() { | |
let a = 0 | |
let b = 1 | |
while(true) { | |
let c = a + b | |
a = b | |
b = c | |
yield b | |
} | |
} | |
const it = dameNumeroFibonacci() | |
console.log(it.next()) | |
console.log(it.next()) | |
console.log(it.next()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment