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 trialnathanielcusano
9,808 PointsAm I understanding the conditional statement correctly?
So basically div has a default value of block. So if the list is displaying that means the value is set to block. Upon clicking the button (while the list is displayed on the screen), the if statement sees that "none" is false. It goes to the else statement and makes two changes: the button now says "show list" and the display value changes to "none" which consequently hides everything within the div element?
1 Answer
Steven Parker
231,269 PointsYou seem to understand that part correctly.
The other condition is when it is already "none" (so the test is true), then the text is set to "hide list" and the display is set to "block" to make it visible again.
So essentially, any button click will change the current visibility and set the text to say the right thing for the next change. Sort of like a light switch.
nathanielcusano
9,808 Pointsnathanielcusano
9,808 Pointsthanks