const promiseOne = new Promise(resolve=>{
setTimeout(()=>resolve(1), 3000)
})
const promiseTwo = new Promise(resolve=>{
setTimeout(()=>resolve(2), 2000)
})
const promiseThree = new Promise(resolve=>{
setTimeout(()=>resolve(3), 1000)
})
const callAllPromiseInAsync = async () => {
const start = Date.now()
const p1 = await promiseOne
const p2 = await promiseTwo
const p3 = await promiseThree
console.log([p1,p2,p3])
console.log( Date.now() - start)
}
When I called this function, it took almost 3 seconds to run instead of 6. Shouldn't it wait 3 seconds for p1, 2 seconds for p2, and 1 second for p3, resulting in a total of 6 seconds?