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 PointsPass addEventListener() a reference to the handleChange function.
Why this one is incorrect T^T
1 Answer
Peter Vann
36,427 PointsHi 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!
Hanwen Zhang
20,084 PointsHanwen Zhang
20,084 PointsUnderstood now, thank you