Welcome to the world of asynchronous JavaScript! In this problem, you'll work with Promises - one of JavaScript's most powerful features for handling asynchronous operations.
You are given two promises: promise1 and promise2. Both promises will eventually resolve with numeric values. Your task is to create and return a new promise that resolves with the sum of these two numbers.
Goal: Create a promise that waits for both input promises to resolve, then returns their sum.
Input: Two Promise objects that resolve to numbers
Output: A Promise that resolves to the sum of the two input numbers
This problem teaches fundamental concepts of promise handling, async/await syntax, and error management in modern JavaScript applications.
Input & Output
Constraints
- Both promise1 and promise2 will resolve with number values
- The promises may resolve immediately or after some delay
- Numbers can be positive, negative, or zero
- Numbers are within JavaScript's safe integer range (-253 to 253)
- The returned value must be a Promise that resolves to the sum