I was rejected from my BirdEye Frontend Software Engineer interview due to this question
I was asked to implement a polyfill for Promise.all, but with a twist:
I was rejected from my BirdEye Frontend Software Engineer interview due to this question

I was asked to implement a polyfill for Promise.all, but with a twist:
Instead of resolving when the longest-running promise finishes (like Promise.all does), the custom implementation had to resolve after the cumulative time of all promises.
I attempted a solution — but it didn’t work as expected.
const promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('promise1 resolved')
}, 1000)
})
// const promise2 = new Promise((resolve, reject) => {
// setTimeout(() => {
// reject("promise2 rejected")
// }, 2000)
// })
const promise3 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("promise3 resolved")
}, 4000)
})
const finalVal = Promise.all([promise1,
// promise2,
promise3
])
function customAll(promises) {
return new Promise((resolve, reject) => {
let ans = [];
promises.forEach((p, i) => {
p.then((res) => {
ans[i] = res;
if (ans.length === promises.length) {
resolve(ans)
}
}).catch((err) => {
reject(err);
})
})
})
}
Promise.customAll = customAll
const finalVal2 = Promise.customAll([promise1,
// promise2,
promise3
])
console.log(finalVal.then((res1) => console.log("res1", res1)), finalVal2.then((res2) => console.log("res2", res2)))
Here’s a near-correct version I came up with (still not perfect):
function customAll(promises) {
return new Promise((resolve, reject) => {
const results = [];
async function runSequentially() {
try {
for (let i = 0; i < promises.length; i++) {
results[i] = await promises[i]();
}
resolve(results);
} catch (err) {
reject(err);
}
}
runSequentially();
});
}
Promise.customAll = customAll;
function createTasks() {
let ans = []
for (let i = 0; i < 4; i++) {
ans.push(() => new Promise((resolve, reject) => setTimeout(() => resolve(`Resolved ${i}`), 1000)))
}
return ans;
}
const tasks = createTasks()
console.log(tasks)
Promise.customAll(tasks).then((res) => console.log(res))
If you have a better solution or thoughts on this, I’d love to hear them in the comments. Your input is truly appreciated 🙏
메타데이터
- post_id
- c1260091f736
- slug
- i-was-rejected-from-my-birdeye-frontend-software-engineer-interview-due-to-this-question-c1260091f736
- url
- https://medium.com/@joinsachinarya/i-was-rejected-from-my-birdeye-frontend-software-engineer-interview-due-to-this-question-c1260091f736
- canonical_url
- https://medium.com/@joinsachinarya/i-was-rejected-from-my-birdeye-frontend-software-engineer-interview-due-to-this-question-c1260091f736
- author_url
- https://medium.com/@joinsachinarya
- status
- ok
- fetched_at
- 2026-07-29 22:20:06