Make a Deferred Promise

Write the code, see it run, pass the checks.

The problem

  • easy
  • Code

Write deferred(): return an object { promise, resolve, reject }. promise is a new, pending promise. Calling resolve(value) fulfils it with value, and calling reject(reason) rejects it with reason, from anywhere and at any later time. Each call to deferred() makes a separate promise.

Your code must pass

  • Returns a pending promise with resolve and reject
  • resolve(value) fulfils the promise with value
  • reject(reason) rejects the promise with reason
  • Each call makes a separate promise