87.delayResolve

Write a function named delayResolve that receives two parameters:

  • a Promise that will definitely resolve, named promise
  • a number of milliseconds, named 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.

Example 1

const instantPromise = new Promise((resolve) => {
    resolve(100)
});

delayResolve(instantPromise, 1000).then((value) => {
    console.log(value); // should print "100" after 1 second
})