I have the following code:
class simplePromise {
constructor(resolveFn, rejectFn) {
console.log(resolveFn, 'resolveFn') // (resolutionFunc, rejectionFunc) => {
// resolutionFunc(777);
// rejectionFunc();
// }
console.log(rejectFn, 'rejectFn') //undefined
}
}
const promise1 = new simplePromise( (resolutionFunc, rejectionFunc) => {
resolutionFunc(777);
rejectionFunc();
});
As you can see, I'm trying to pass in 2 functions to the constructor. However, when I console.logged each of them out, I noticed that both functions are registered as 1 argument. In this case, how do I separate the 2 functions?
new simplePromiseinstance. That function you are passing tonew simplePromisetakes two arguments, which you would be passing toresolveFn. You never even callresolveFn(resolutionFuncPassedHere, rejectionFunctionPassedHere)... I'm pretty sure you're still confused about the way it works, at this point. Practice, practice practice.