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 DOM Scripting By Example Adding and Removing Names RSVP Checkbox

Aren't constants suppose to be immutable?


At 0:54, Guil sets a constant, then he adds to that constant on a new line, shouldn't this be impossible to happen? I thought 'const' couldn't be altered once declared.

A lil confusing, Thanks.

1 Answer

Steven Parker
Steven Parker
229,645 Points

You're right, the "label" is a constant and cannot be changed. But the properties of the element it refers to can be, which is what is happening here. This is the same as what was done with "li" on lines 9 and 10.

The object itself (the new element) is not constant, only the variable "label" that references it. You would not be able to assign anything else directly to "label".