Question 6
Back to Exercise
getUser() and getOrders() are independent and each takes 1 second. Which code finishes in about 1 second?
- A const u = await getUser(); const o = await getOrders();
- B await getUser(); await getOrders();
- C const [u, o] = await Promise.all([getUser(), getOrders()]); Correct
- D await (getUser(), getOrders());
Correct Answer: Option C
Promise.all starts both before waiting. Two sequential awaits take about 2 seconds; the comma version only awaits the second.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!