**Can someone show me how to generate Fibonacci numbers using the for...of loop in JavaScript?**
I've tested out the following code and it's giving me the desired output:
function createFibonacci(number) {
var i;
var fib = []; // Initial array set up
fib[0] = 0;
fib[1] = 1;
for (i = 2; i <= number; i++) {
// Logic to find next Fibonacci number
fib[i] = fib[i - 2] + fib[i - 1];
console.log(fib[i]);
}
}
createFibonacci(8);
Although this works fine, I'm curious if there's a way to achieve the same result using the for..of loop. Is there any method available for this?