Created
January 26, 2017 01:27
-
-
Save bbarrows/f8a376474580ae2cf0053defdf4b0473 to your computer and use it in GitHub Desktop.
This file contains 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
let fibonacci = { | |
[Symbol.iterator]() { | |
let pre = 0, cur = 1; | |
return { | |
next(p) { | |
console.log(p); | |
pre = cur | |
cur = pre + cur | |
//[pre, cur] = [cur, pre + cur]; | |
if (cur < 100) { | |
return { done: false, value: cur } | |
} else { | |
return {done: true} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment