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

All guests are hidden when I click button "Hide those who haven't responded"

2 Answers

Hannah Cherba
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Hannah Cherba
Front End Web Development Techdegree Graduate 14,319 Points

I took a look at your code and your missing an if else statement in the ul event handler. When I added the if statement the program ran perfect. The reason you add the If-Else statement is to determine if the box is checked (true) or unchecked (false):

ul.addEventListener('change', (e) => {
    const checkbox = event.target;
    const checked = checkbox.checked;
    const listItem = checkbox.parentNode.parentNode;

    if (checked) { //This if else statement fixed the problem ;D 
      listItem.className= "responded";

    } else {
      listItem.className= '';
    }


});
Laura Coronel
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Laura Coronel
Treehouse Teacher

Hey Alice McElyea awesome work so far! I recommend watching the RSVP Checkbox video. It looks like your event listener for the confirmed button doesn't have the if statement that adds the class name "responded" to the list item if the confirmed button was checked. Once you add that the "Hide those who haven't responded" button should start working!