Implement a function promiseResolve(value) that mimics the behavior of Promise.resolve.
The function should:
value is already a Promise, return it as is.value is a thenable (an object with a then method), adopt its eventual state.Examples
promiseResolve(42).then(console.log); // 42 promiseResolve({ then: res => res("hello") }).then(console.log); // "hello" const p = Promise.resolve("world"); promiseResolve(p).then(console.log); // "world"
JavaScript Function
No test results yet
Click "Run" to execute tests