How can I wait until the function a is complete, but is not working as I expected.
Here is my code:
var start = Date.now();
function a() {
setTimeout(function(){ console.log(Date.now() - start); }, 500);
for(var i=0; i<100; i++) {
console.log(i);
//
}
}
const main = async () => {
await a();
console.log("Done");
};
main().catch(console.error);