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 trialBirthe Vandermeeren
17,146 PointsWhy do you have a line of code for when the class name is 'responded'?
I used .visibility = 'hidden' instead of .display = 'none' in my code, but nevertheless, why do you have a line of code for when the class name is 'responded'? I just check with an if statement if .className !== 'responded' and then set the visibility to hidden.
Here's my code: https://w.trhou.se/q8v8al1ebt
Birthe Vandermeeren
17,146 PointsThanks for your reply, Anastasios! I think my question wasn't clear enough. I too checked the class, but checked for it to not be equal to responded instead of it to be equal to responded. In the else statement, i set them to visible, while Guil sets display to none in the else statement. I wanted to know if there's a reason for doing so, if that's the better way to do it. I my head it makes more sense to do it like I did. :) Doesn't really matter I guess.
2 Answers
Anastasios Poursaitedes
10,491 PointsI think I get what you're saying. I assume that Guil put the else for readability. You can omit the else clause if you check for the list item to not have the class responded, like you did.
Birthe Vandermeeren
17,146 PointsThanks, Anastasios!
Kristaps Buls
3,656 PointsI kind of was thinking that also. you get 3 lines less if you just write. if (li.className !== 'responded') { li.style.display = 'none'; } no else needed.
Anastasios Poursaitedes
10,491 PointsAnastasios Poursaitedes
10,491 PointsHello Birthe, we check if the list item has the class responded to distinguish it from the other list items that haven't been checked. There are other ways to find which of them are checked, not necessary difficult but they require more code. The class checking is brief and intuitive I think.