function fibonacciGenerator(n) {
    //Do NOT change any of the code above 👆

    //Write your code here:

    let output = [];
    if (n === 1 || n === 0) {
        output = [0];
    } else if (n === 2) {
        output = [0, 1];
    } else {
        output = [0, 1];
        for (var i = 2; i < n; i++) {
            output[i] = output[i - 1] + output[i - 2];
        }
    }

    //Return an array of Fibonacci numbers starting from 0.
    return output;
    //Do NOT change any of the code below 👇
}
output = fibonacciGenerator(3);
console.log(output);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: