Your Submissions
You haven't submitted any code for this challenge yet. Solve the problem by passing all the test cases, and your submissions will appear here.
xxxxxxxxxx
16
Promise.all = (promises) => {
return new Promise((resolve, reject) => {
const results = []; // Array to store the results of the promises
// TODO: Check if the promises array is empty, and if so, resolve with the empty results array
let pending = promises.length; // Counter for the number of pending promises
promises.forEach((promise, idx) => {
// TODO: Resolve each promise and store its result in the results array
// If all promises are resolved, call resolve with the results array
// If any promise is rejected, call reject
});
});
};
OUTPUT
Results will appear here.