Implement a function promiseWithResolvers() that creates a new Promise along with its resolver functions.
The function should:
promise: the new promise instance.resolve: a function to resolve the promise.reject: a function to reject the promise.resolve or reject changes the state of the returned promise.Examples
const { promise, resolve, reject } = promiseWithResolvers(); setTimeout(() => resolve("done"), 1000); promise.then(console.log); // "done"
JavaScript Function
No test results yet
Click "Run" to execute tests