First, thanks alot for anybody who will have a look at my question. It is totally basic but I just don`t get it. I have looked through all tutorials, but asynchronous callbacks drive me crazy. Thank you so much for helping out, greetings from Germany :)
If somebody could tell me why below code does not log into the console as expected. Expected means, callback is called after the Timeout function has completed. Instead, my console logs the callback first? What am I still getting wrong here?
function doHomework(subject, callback) {
setTimeout(function () {
console.log(`Starting my ${subject} homework.`);
}, 10);
callback();
}
doHomework('math', function() {
console.log('Finished my homework');
});