es6-features
es6-features copied to clipboard
Fibonacci numbers issue
Hi there! First, I want to say thanks for a great features overview. GeneratorFunctionIteratorProtocol good as example of generator but not fully correct Fibonacci numbers. An output of this example is 1, 2, 3, 5, 8, 13 ... And should be: 1, 1, 2, 3, 5, 8, 13 Yield can be placed before calculating the next iteration.
...
for (;;) {
yield cur;
[ pre, cur ] = [ cur, pre + cur ]
}
...