Stuck on Learn JavaScript/Promises 3. Constructing a Promise Object/Instruction 2

Not sure where to find specific tags for this part of the lesson:

(Learn JavaScript/Promises 3. Constructing a Promise Object/Instruction 2)

My problem is that the hint hasn’t helped me clear whatever syntax or similar error I have made:

I succeeded on Instruction 1 with:
// Write your code below:

const inventory = {
sunglasses: 1900,
pants: 1088,
bags: 1344

const myExecutor = (resolve, reject) => {
if (inventory.sunglasses > 0) {
resolve(‘Sunglasses order processed.’);
} else {
reject(‘That item is sold out.’);

Instruction 2 asks " Create a function, orderSunglasses() . This function should have no parameters. It should return a new promise constructed by passing your myExecutor() function into the Promise constructor."

My solution for Instruction 2 is:
// Write your code below:
const orderSunglasses() = new Promise(myExecutor);

This is a lot like the hint, copied here:

You’ll need to use the new keyword and the Promise constructor method to create a new promise object:

new Promise(anExecutorFunction);

Remember to pass the function in without invoking it and make sure your orderSunglasses() function returns the promise.

The only difference I can see is that the hint uses an example function with a slightly different name (anExecutorFunction) from mine (myExecutor).

I just don’t see a syntax error or typo - though I will admit, I have trouble seeing these initially. I’ve waited over a day to post this because retyping/copying from the hint or copying from my own function code does not seem to fix anything.


Hi @script6702555774

A const name can never be a function call.


Thank you, mirja_t -

After numerous iterations, I finally landed on the successful solution:

//Write your code below:

function orderSunglasses() {
return new Promise(myExecutor);}

It was a little more confusing than some other exercises because there’s no example of defining a function to return the object constructed by the Promise constructor.

1 Like