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 JavaScript Basics Making Decisions in Your Code with Conditional Statements Test Multiple Conditions With the && Operator

Joseph Michelini
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Michelini
Python Development Techdegree Graduate 18,692 Points

Why 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
Steven Parker
231,269 Points

Variables should only be declared once. Clearing the console doesn't destroy the variable, so it still exists and can be reassigned.

Steven Parker
Steven Parker
231,269 Points

Deleting 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!

If 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.