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

Crystal Vesely
Crystal Vesely
14,199 Points

In a loop, do variables reset after every iteration?

I am trying to understand when to use let vs const. When creating a variable in a loop, does the variable reset with each iteration? And what about nested loops? Do they follow the same rules? If they reset, it makes logical sense that you would use const for the variable, but if they don’t reset, then it makes sense to me that you would then need to use let.