function promiseRace(promises) {
let arr = [];
for (const elem of promises) {
elem.then(() => {
arr.push(elem)
})
}
return arr[0]
}
const firstPromise = new Promise((resolve) =>
setTimeout(() => resolve(300), 300)
);
const secondPromise = new Promise((resolve) =>
setTimeout(() => resolve(200), 200)
);
const thirdPromise = new Promise((resolve, reject) =>
setTimeout(() => resolve(100), 100)
);
console.log(promiseRace([firstPromise, thirdPromise, secondPromise]))