Skip to content

Instantly share code, notes, and snippets.

@fuchao2012
Created February 23, 2017 07:39
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 fuchao2012/ecc8495b3bf555b6d93536abd3a05b5e to your computer and use it in GitHub Desktop.
Save fuchao2012/ecc8495b3bf555b6d93536abd3a05b5e to your computer and use it in GitHub Desktop.
fib-generator tags: #ES6
function* fib(){
let a=1, b=1
yield a
yield b
while(true){
let next = a+b
a=b
b=next
yield next
}
}
let gener = fib()
for(let i of Array(10).keys()){
console.log(gener.next().value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment