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 trialJoseph Michelini
Python Development Techdegree Graduate 18,692 PointsWhy is the variable age declared only once in this example?
Does the console remember let age = ; ? After typing that the first time and clearing the console, it seems he can reassign a number to age without declaring it as a variable again.
Thanks in advance!
2 Answers
Steven Parker
231,248 PointsVariables should only be declared once. Clearing the console doesn't destroy the variable, so it still exists and can be reassigned.
Abdullah Howard
11,955 PointsIf by โclearโ you mean destroy then you cannot destroy variables declared with keywords (var, let, const). The console just reads the code youโve written, it doesnโt remember it.
Joseph Michelini
Python Development Techdegree Graduate 18,692 PointsJoseph Michelini
Python Development Techdegree Graduate 18,692 PointsThanks Steven! What if I wanted to clear the console and clear the declared variables as well?
Steven Parker
231,248 PointsSteven Parker
231,248 PointsDeleting a variable would normally not be necessary, you can simply ignore it. But since you're working in a browser, you can refresh the page to reset conditions to what they were when the page first loaded, which will also wipe out any new variables that were created.
Happy coding!