Exercise 12: Promise Delay (with value)
Problem Statement
Function `delay(ms, value)` banao jo ms ke baad value resolve kare.
Example: delay(1000, "hello") => resolves after 1s with "hello"
Sample Output:
await delay(1000, "hello") => "hello" (after 1 second)
Solution
const delay = (ms, value) => new Promise(resolve => setTimeout(() => resolve(value), ms));Explanation
Overall Goal:
- Delay ke baad value resolve karna.
Real world:
- Testing: delayed responses.
- Animations: delayed actions.