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.


Alexandros S.
Alexandros S.
8,261 Points

Code still works after commenting it out.

So I tried out some code from a question in a quiz from the "JavaScript Basics" because I didnt understand it very well.

// name = "Trish";
function setName() {
  var name = "Sarah";


When I ran the code in my browser an alert opened saying "Trish". But how is that possible when " // name = "Trish"; " is commented out?!

1 Answer

Codin - Codesmite
Codin - Codesmite
8,600 Points


Seems to work correctly for me, removing the comments outputs Trish in the alert box and adding them back removes Trish.

Check the files on your server are correct and try clearing your browser cache, as it may be loading the page or variable from cache.


Alexandros S.
Alexandros S.
8,261 Points

Thanks, it worked properly after clearing chrome's cache and restarting it.