Firstly The code below prints the value from the call()
function which it returns though it takes some time to execute, then it prints the next line.
But I want to make it async behavior so that it first outputs the last line(which execution time is less) than the previous (higher exec time). How can I do that?
function call() {
let counter = 0;
for (let i = 0; i < 40000; i++) {
for (let j = 0; j < 50000; j++) {
counter++;
}
}
return counter;
}
console.log(call());
console.log('loading ... ');