Skip to content

Instantly share code, notes, and snippets.

@RosanaRufer
Created February 20, 2019 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RosanaRufer/b0373f5a4c298ee16f87fd4fdc8b8367 to your computer and use it in GitHub Desktop.
Save RosanaRufer/b0373f5a4c298ee16f87fd4fdc8b8367 to your computer and use it in GitHub Desktop.
A JavaScript Iterator
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