JSFiddle - React, Tailwind, and code Playground

by Weston Ruter

HTML

<html>
    <body>
        <button onclick="FunctionQueue.start()" >Test</button>
    </body>
</html>

JavaScript

function test() {
    FunctionQueue.next();
}

function hello() {
    FunctionQueue.next();
}

function cool() {
    FunctionQueue.next();
}

function world() {
    alert('Hello world!');
    FunctionQueue.next();
} 

var FunctionQueue = {
    functions: [
        test,
        hello,
        cool,
        world
    ],
    current: 0,
    start: function () {
        this.current = 0;
        this.next();
    },
    next: function (){
        if (this.current + 1 >= this.functions.length) {
            return null;
        }
        else {
            this.current += 1;
            this.functions[this.current]();
        }
    }
};