-1

I have the following code:

let a = async () => {
    let b = await c()
    console.log(b)
}

let c = () => {
    setTimeout(async () => {
        return true
    }, 0)
}

a()

In a(), I want c() to wait until its setTimeout has finished and returned the true value before assigning it to b. So I want the console.log to log true instead of undefined. Can anyone explain why it's returning undefined and advise me on how to modify it to return true?

gkeenley
  • 4,302
  • 3
  • 25
  • 80

0 Answers0