Is it possible to run functions in order but only execute after the previous function has completed?I would like the output to be 1 2 3 4 but I get 1 2 4 3.async function foo() { await step1(); await step2(); await step3(); await step4(); } function step1(){ console.log("1"); } function step2(){ console.log("2"); } function step3(){ setTimeout(function () { console.log('3'); }, 1000) } function step4(){ console.log("4"); } foo();
Submitted June 30, 2018 at 04:00AM by scoboose
No comments:
Post a Comment