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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Colin Sandlin](https://secure.gravatar.com/avatar/0dc684a2187c59503c6cfe5e88e15cd3?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Colin Sandlin
4,512 PointsUnderstanding the "checked" value
I'm having a bit of trouble wrapping my mind around this line, at about 5:50 of the video -
const checked = checkbox.checked;
// how does checkbox.checked work?
//I understand it's a true or false value, but why doesn't it have to have an 'if true' statement?
3 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsYou're right, it will require an "if" statement to test the value. By itself, the assignment doesn't cause any decision to be made by the code. Continue on in the video until about 6:50 and you will see this statement written:
if (checked) {
Isn't that exactly what you were expecting?
![Colin Sandlin](https://secure.gravatar.com/avatar/0dc684a2187c59503c6cfe5e88e15cd3?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Colin Sandlin
4,512 PointsSteven, thanks for your reply. That is what I was expecting, however I still can't seem to understand what the checkbox.checked is doing or how that line operates prior to the 'if' statement?
I'm not sure if my question is making sense, sorry!
![Colin Sandlin](https://secure.gravatar.com/avatar/0dc684a2187c59503c6cfe5e88e15cd3?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Colin Sandlin
4,512 PointsAh, yes it does. I think the syntax of the variable being named 'checked' and having that same terminology later in that line was messing with me. I appreciate your patience.
Steven Parker
230,688 PointsSteven Parker
230,688 PointsThe assignment line just puts a "true" or "false" value into the constant named "checked". This value represents the condition of the box at the moment the assignment runs. The value will be "true" if the box is checked, and "false" if it is not. But on this line, the value is only stored. Is isn't tested until later by the "if".
Does that answer your question?