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 trialbaderbouta
7,804 PointsAren't constants suppose to be immutable?
Hi,
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
231,248 PointsYou'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".