the JavaScript code below shows that the line "b" works before line "a" because line a needs some time to finish
I want line "b" to work after line "a"
var time = Math.floor(Math.random() * 11) * 1000;
function tt(){ // example function with unknown time to end
var tts = setInterval(function() {
document.getElementById("a").innerHTML = "a";
clearInterval(tts);
}, time);
}
//----------------
tt(); //line a
document.getElementById("b").innerHTML = "b"; //line b
<p id="a"></p>
<p id="b"></p>