JSFiddle - React, Tailwind, and code Playground

JavaScript

"use strict";

function log(s) {
    var line = document.createElement('div');
    line.textContent = s;
    document.body.appendChild(line);
}

function foo(clb) {
    setTimeout(function() {
        clb('A');
    }, (Math.random()*100)|0);
}

function bar(clb) {
    setTimeout(function() {
        clb('B');
    }, (Math.random()*100)|0);
}

function baz(clb) {
    setTimeout(function() {
        clb('C');
    }, (Math.random()*100)|0);
}

/**

    change the code below to provide a guaranteed output as follows:
        A
        B
        C

**/

foo(log);
bar(log);
baz(log);