Skip to content

Instantly share code, notes, and snippets.

@bbarrows
Created January 26, 2017 01:27
Show Gist options
  • Save bbarrows/f8a376474580ae2cf0053defdf4b0473 to your computer and use it in GitHub Desktop.
Save bbarrows/f8a376474580ae2cf0053defdf4b0473 to your computer and use it in GitHub Desktop.
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