DEV Community

Jen C.
Jen C.

Posted on

LeetCode - Solution for 2723. Add Two Promises

The first attempt:

type P = Promise<number>

async function addTwoPromises(promise1: P, promise2: P): P {
    return (await Promise.all([promise1, promise2])).reduce((a: number, b: number) => {
        return a + b;
    }, 0);
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)