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

why does the let variable display an error when you put it more than once?

i thought that since we're using it when we want something to keep changing, it would make sense to have it work when you put more than one?

2 Answers

Instead of using the let keyword each time you use the variable, try

let someValue = 1;
someValue = 2;

where you declare the variable once and just use the variable name afterwards.

mouseandweb
mouseandweb
13,758 Points

you may declare a variable only once. Afterward you may reassign a value to the variable, but without using a keyword like let or const.

ohh so when you make a new variable each one is completely different. i get it now