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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Wendy Cortes](https://secure.gravatar.com/avatar/158e4962ea6d6b18dc2e02ad80112c04?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Wendy Cortes
Full Stack JavaScript Techdegree Graduate 16,375 PointsFor 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](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsJust 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.
JASON LEE
17,352 PointsJASON LEE
17,352 PointsThis has been the hardest part for me when understanding promises. The callback function, parameter, argument, etc.
For instance, just looking at this part
mathPromise.then(addFive)
The return or resolved (value) from
mathPromise
is implied as passed as an argument. At least that's the way I think of it.mathPromise.then(addFive)
===mathPromise.then(value => addFive(value))
In the left side of the equation, even though
value
isn't explicitly written out, it's implied.Someone please feel free to correct me if I'm mistaken.