I have started to learn JavaScript and am trying to figure out how to achieve this?
console.log(1);
setTimeout(() => {
console.log(2);
}, 2000);
console.log(3);
We know that the output is 1,3,2
How can I get the output in the order it is given.
Example: It should print 1,then it should wait for 2 seconds and then print 2 and it should print 3.