Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
How would I make these await functions run sequentially?

I was wondering what was going on in the following code block:

    async function test() {
        function work() {
          console.log("work");
        }

        await setTimeout(work, 5000);
        await setTimeout(work, 1000);
        await setTimeout(work, 5000);
        await setTimeout(work, 1000);
        await console.log("Hello")
      }

This code block takes 5 seconds total to run and 'Hello' is logged immediately, implying all the functions are executing at the same time. How would I make these functions run sequentially without using Promise.all()? Why is this behavior occuring?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!