Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
216,149 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
216,149 Points

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