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

Quality Assurance

How come you can keep redeclaring variables with const?

Once you declare a variable with const I thought it meant that it became fixed globally. In the video, I am not sure if everytime you declare ' const driver = new selenium.Builder().forBrowser("chrome").build(); ' to open a driver you are exiting the REPL, then re-entering before you declare the variables again? If I don't do that I get a SyntaxError, which I would expect. Am I missing something or should I just use a different variable name if I'm not exiting the REPL?

I don't know if its clear I'm referring to the WebDriver videos

1 Answer

Steven Parker
Steven Parker
231,248 Points

You should probably post a question like this in the category of the appropriate language (you can move it using "edit question").

But assuming it's JavaScript (or something with similar syntax) you can re-do a "const" declaration in a function or a loop because any previous variable has gone out of scope and been disposed before you create the new one.

Thanks, it was specifically about a video, it wasn't in a function or a loop, just in command line. Don't worry about it, I'll just chalk it up to the mysteries of this place, along with why I can't put the question on the page of the video.

Steven Parker
Steven Parker
231,248 Points

You could also post a link to the video page, with a time index of where you saw the issue.