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

Nick Miller
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Nick Miller
Full Stack JavaScript Techdegree Graduate 21,991 Points

What is the event listener supposed to look like on this?

I'm passing this quiz but I'm confused by why my answer didn't work here. The call back function I used as an event handler was () => handleChange() . Would that not work in producing the desired effect?

1 Answer

Nick Miller
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Nick Miller
Full Stack JavaScript Techdegree Graduate 21,991 Points

Hi Oliver,

That's not working in the quiz. Here's the code with the event listener included:

select.addEventListener('change', ()=> handleChange);

I've also tried including the () after handleChange.

Here's the full code of the question on the quiz:

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

select.addEventListener('change', //Fill in here);

Remember: the function "handleChange" is already decleared on top, therefore you don't have to add an arrow function to de eventListener just call the one already decleared.

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

select.addEventListener('change', handleChange);