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 trialSamira Tavakolli
6,715 Pointslet or const?
I did this excercise but I used let instead of const; assuming that what value will be assigned to them (like noune, adjective or verb) will be change by evetytime we answer to them on the web page. But from the other hand I see the instructor has used const, assuming that the prompt method inside the variable is always the same!!! Why should we refer to the method inside the variable and not the output value?
2 Answers
Steven Parker
231,269 PointsYou forgot to provide a reference to the course page (for future questions, see this video about Posting a Question), so it's not clear what you mean about "the method inside the variable".
But const only protects a variable content during a single run of the program. When the program is run another time, it's fine for the value to be different from the previous run.
The common practice is to always use const to define something that doesn't change while the program is running, which is why the instructor used it. Substituting "let" in a properly written program will have no functional impact.
Samira Tavakolli
6,715 PointsThanks Steven, I believed I was posting under the video of the challege by pushing "Ask" key right above it! Sorry!!! and your answer has clarified anyway what I was not understanding!