You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Promise.race(): takes an array of promises and waits for the first promise in the array to complete before resolving or rejecting based on it's result.
const arrayOfPromises = [];
for(let i = 0; i < 5; i++) {
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
// resolve a random number between 0 and 100
resolve(Math.floor(Math.random() * 100));
// wait a random amount of time between 0 and 5 seconds