2859. Add Two Promises
My accepted JavaScript solution to LeetCode problem 2859, Add Two Promises, running in 57ms.
- Difficulty: Easy
- JavaScript
- Runtime 57ms
- Memory 54.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
JavaScript
Accepted on LeetCode — runtime 57ms, memory 54.3MB, accepted 2025-12-31.
/**
* @param {Promise} promise1
* @param {Promise} promise2
* @return {Promise}
*/
var addTwoPromises = async function(promise1, promise2) {
const [val1, val2] = await Promise.all([promise1, promise2]);
return val1 + val2;
};
/**
* addTwoPromises(Promise.resolve(2), Promise.resolve(2))
* .then(console.log); // 4
*/