Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Nick Huemmer
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Nick Huemmer
Front End Web Development Techdegree Graduate 26,840 Points

The "Final" version of the code for this video doesn't have have any parameters in the `new Promise` function.

I'm coding along with Guil using the files downloaded into VS Code. I was getting an error when I ran the code I copied with node, so I referred to the finished code and noticed that the anonymous function in the new Promise function didn't have any parameters passed into it. It looks like this:

const breakfastPromise = new Promise( () => {
    setTimeout(() => {
        resolve('Your order is ready. Come and get it!');
    }, 3000);
});

console.log(breakfastPromise);
breakfastPromise.then( val => console.log(val))

I was using this code as a reference to troubleshoot the error I was receiving in the console. I was able to figure it out and get it to work (not sure exactly what was going on). I'm just wondering if this is an error in the code or there's something I'm missing.

Here's my code that I ran in the terminal (Git Bash since I'm on Windows and I don't think my VS Code has node installed...or at least it's not working) and in the console in Firefox:

const breakfastPromise = new Promise( (resolve, reject) => {
  setTimeout(() => {
    resolve('Your order is ready. Come and get it!');
  }, 3000);
});

console.log(breakfastPromise);
breakfastPromise.then( val => console.log(val))

Anyway, may not be worth digging into further now that I got it to work, but maybe this will help someone else.

1 Answer

Robert Manolis
STAFF
Robert Manolis
Treehouse Guest Teacher

Hi Nick Huemmer, can you share a link to the video, stage or course pretty please, so we can look into this. :thumbsup: