I've stumbled upon this question.
My instinct tells me the sum
should be 3
. Could someone explain what is actually happening?
let sum = 0;
async function add(num) {
sum += await num;
}
add(1);
add(2);
setTimeout(() => console.log(sum), 100);