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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more