JavaScript Node.js Basics Building a Command Line Application Making a GET Request with https

Marcus Schumacher
Marcus Schumacher
12,185 Points

Why use const here?

He said we'll store the username in a variable so we can change it later. Then he makes a constant variable called username to store the name. Why would you use const? Wouldn't that make it impossible to change the username later? Wouldn't var be just fine here? Sorry for my ignorance, but I haven't really used const that much and still don't fully understand it I guess :/

1 Answer

Erik Krieg
MOD
Erik Krieg
Treehouse Moderator 43,037 Points

You are right, values declared as a const cannot be changed in a running program. What I believe is meant here by "change later" is refactor references to the username in the code more easily. He is just promoting DRY code where the "chalkers" username isn't repeated.