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 would you use let message for the variable on line 2 instead of just message?

I am working through the JavaScript basics course and am wondering when to use let for a variable instead of just the variable name.

1 Answer

Robert Manolis
STAFF
Robert Manolis
Treehouse Guest Teacher

Hey Melanie Gunn , when you are first declaring a variable, you need to use either var, let or const to correctly instantiate that variable. Then later, when you reference or reassign the variable, you will not use one of those keywords, but just the variable name. Hope that is helpful. :smiley:

I can't comment on the line 2 of the code you are referring to because I don't know what that is. When reaching out here, it can be helpful to share any example code and relevant links, like to the course, video or challenge you are working on and perhaps a workspace snapshot. :thumbsup:

Thank you! I figured it out. That is good to know for next time that I need to post a screenshot of my work.