Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Asynchronous Programming with JavaScript Understanding Promises Promises Review

Wendy Cortes
.a{fill-rule:evenodd;}techdegree seal-36
Wendy Cortes
Full Stack JavaScript Techdegree Graduate 15,450 Points

For the example of mathPromise, why .then(addFive) and not .then(addfive(value))

for this part:

const value = 5; mathPromise .then(addFive) .then(double) .then(finalValue) .catch( err => console.log(err) )

How are we calling the functions inside the methods without including the parameter value?

1 Answer

Steven Parker
Steven Parker
218,636 Points

Just naming the function doesn't call it, it passes it to the handler which will call it later when the "then" condition is satisfied. At that time, it will be passed the value which the "then" is waiting for.

It wouldn't make sense to call it right now since the value needed to pass to it isn't available yet.