Learn Intermediate JavaScript

https://www.codecademy.com/courses/learn-intermediate-javascript/lessons/promises/exercises/onfulfilled-onrejected

I just can’t understand this page.

My answer was accepted for question #1. Below is my solution for question #1:

let prom = new promise ((resolve, reject) => { resolve( "Thank you. Your order was successful."); } else { reject(“We’re sorry. Your order could not be completed because some items are sold out”) }; }; });

but when I got to the second question, I had to use the ‘view solution’ option which has the answer as

const handleSuccess = (resolvedValue) => {
console.log(resolvedValue);
};

const handleFailure = (rejectReason) => {
console.log(rejectReason);
};

checkInventory(order)
.then(handleSuccess, handleFailure);

Unless I’m mistaken, there is no reference to the question #1 at all. Additionally, I don’t understand how I should use the ‘setTimeout()’ function mentioned in question #1.

Can someone please help me understand?

Thank you.

Hey,
in step one they just explain to you what they’ve written in the file library.js. You should not write anything before step 2 – just look at their code. That’s what you get the check for.

1 Like

Oh Okay! Thank you so much!!

1 Like