1let fibonacci = [0, 1]; // set initial conditions
2
3for (let i = 2; i < 10; ++i) {
4 // add the two previous elements to get the current element
5 fibonacci[i] = fibonacci[i - 2] + fibonacci[i - 1];
6}
7
8console.log(fibonacci); // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]