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 JavaScript Basics Working with Strings Variables and Strings Challenge Solution

Yazeed Hani
Yazeed Hani
5,002 Points

let vs. const

Why was 'const' used instead of 'let' to declare variables?

2 Answers

Hello Yazeed!

const is used when declaring a variable that will not change in value. let is used to declare a variable when you want to update the value later. This is helpful because you won't be able to accidentally change some variable value when using const.

I hope that makes a little more sense!

Elfar Oliver
Elfar Oliver
3,924 Points

Think of const as constant. It won't change throughout the program. He mentioned player score in previous videos and you would use let to start at zero and increase the score and then use const as a goal that won't change