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 Asynchronous JavaScript with Callbacks Callback Functions Review

Gregory Ford
Gregory Ford
7,109 Points

Having trouble setting the function here for the callback function.. ?

This question has been confusing me. I have watched the video linked to this for reference but I am still unable to figure out how to do this. Does anyone know what I am doing wrong here? I've tried different responses but my answer here is the one I felt should've been correct. Thanks in advance!

2 Answers

There are 2 questions in the quiz that reference a callback function. One asks you to "Pass addEventListener() a reference to the handleChange function." In this question, it wants to make sure you understand that when you pass the reference to a callback function, you only put in the name of the function, and do not follow it with parentheses. The other asks you to "Set the makeMeal function to invoke the callback function passed to it." In this one, you simply call the function that is passed in. In this case, the parameter that represents the callback function is named cb, so you would simply call cb(). If the function that was passed in required a parameter, you would likely have called cb(meal), but since it is just printing an alert that doesn't require a parameter, you simply call the function without parameters.

josephweiss2
josephweiss2
6,919 Points

Thanks Jason! Just also had problems as I tried to pass it the meal or getMeal but was an error, and yes didn't realise that its just an empty function so no need to pass it anything