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 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
7,782 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