I remember in the lecture, Mosh was talking about how the return value of a function with its return in setTimeout would be updated after the value was eventually returned.
I am not seeing that, however, when I write my own code:
function asyncBoilWater() {
setTimeout(() => {
return ("Water is boiled.")
}, 3000);
}
let isWaterBoiled = "whatever";
isWaterBoiled = asyncBoilWater();
console.log(isWaterBoiled);
setTimeout(() => console.log(isWaterBoiled), 5000);
I am getting undefined
and then another undefined
. Did I misunderstand him?