JSFiddle - React, Tailwind, and code Playground

by orkatek

HTML

<div id="buttons">

</div>

CSS

#buttons a {
	padding-left: 1%;
}

JavaScript

var progress = 0,
	nums = [1, 2, 3, 4].sort(function() {
        return .5 - Math.random();
    });

for (var i = 0; i < nums.length; i++) {
    var btn = document.createElement('a');

    btn.id = nums[i];
    btn.innerHTML = i + 1;
    btn.onclick = function(e) {
        if (e.currentTarget.id == progress + 1) {
            if (++progress == nums.length)
                alert("Finished");
        } else {
            alert("Incorrect");
        }
    };

    document.getElementById('buttons').appendChild(btn);
}