JSFiddle - React, Tailwind, and code Playground

JavaScript

var async = Function.prototype.call.bind(function () {
    setTimeout.bind(null, this, 0).apply(null, arguments);
});

function forEach(array, funct, callback, error) {
    if (array.length && !error)
    async(funct, array[0], forEach.bind(null, array.slice(1), funct, callback));
    else async(callback, error || null);
}

var a = [0, 1, 1, 2, 3, 5, 7];
var b, c;

forEach(a, fibonacci, done);

function fibonacci(element, next) {
    if (!b && element === 0) {
        b = element;
        next();
        return;
    }

    if (!c && element === 1) {
        c = element;
        next();
        return;
    }

    if (element === b + c) {
        b = c;
        c = element;
        next();
    } else next(element);
}

function done(error) {
    if (error) {
        a.pop();
        b = c = null;
        alert(error + " is not a Fibonacci number!");
        forEach(a, fibonacci, done);
    } else alert("The Fibonacci sequence is: " + a);
}