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

Pass addEventListener() a reference to the handleChange function.

Why this one is incorrect T^T

1 Answer

Hi Hanwen!

When they say "pass a reference to the function", that just means the name of the function.

For example: playSound would be how you type that function as a passed-in parameter (meaning you leave the parens off, because you're not calling/running it yet).

When you then run it in the body of the function it was passed into, however, you'd use playSound();

Therefore the answer is:

function handleChange() {
  console.log('I was changed!');
}

select.addEventListener('change', handleChange); // Passed in only so far, and will run/execute only when select changes

I hope that helps.

Stay safe and happy coding!

Understood now, thank you