2648. Generate Fibonacci Sequence ¶ TypeScript 1 2 3 4 5 6 7 8 9function* fibGenerator(): Generator<number, any, number> { const arr = [0, 0, 1]; while (true) { yield arr[1]; arr[0] = arr[1]; arr[1] = arr[2]; arr[2] = arr[0] + arr[1]; } }