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 trialHanwen Zhang
20,084 PointsWhat is the answer to this question and what is the rationale for this question?
return cb();
1 Answer
Peter Vann
36,427 PointsHi Hanwen!
cb is the callback function that is passed into the makemeal function as a parameter.
Having passed it in, it would make sense to then execute it at some point inside the execution of makemeal (otherwise, what's the point of passing it in?!?).
So for this:
function makeMeal(meal, cb) {
alert(`Preparing ${meal}.`);
cb(); // YOU WANT TO CALL the cb funtion to execute it. (However, there's no need to return it, you're just running it.)
}
makeMeal('lunch', () => { // This is cb passed in as an anonymous function argument
alert('Finished the meal!');
});
I hope that helps.
Stay safe and happy coding!
Hanwen Zhang
20,084 PointsHanwen Zhang
20,084 PointsThank you Peter!!