Write a function named delayResolve
that receives two parameters:
promise
millis
The function should return a new Promise that will resolve with the same value as the promise
parameter, but not sooner than millis
milliseconds.
In other words, if the promise
parameter resolves sooner than millis
then we need to wait until millis
milliseconds have passed before resolving the new Promise.
const instantPromise = new Promise((resolve) => {
resolve(100)
});
delayResolve(instantPromise, 1000).then((value) => {
console.log(value); // should print "100" after 1 second
})