Write a function `delayedValue(val)` that returns a Promise which resolves with `val` immediately.
Problem Statement
Write a function `delayedValue(val)` that returns a Promise which resolves with `val` immediately.
Complexity
Time Complexity: -
Space Complexity: -
Hints
š” Hint 1:
A Promise is created with: new Promise((resolve, reject) => { ... }).
š” Hint 2:
Call resolve(val) to fulfill the promise with the given value.
š” Hint 3:
You can also use Promise.resolve(val) for immediate resolution.
ā
Solution:
```javascript
function delayedValue(val) {
return Promise.resolve(val);
}
```