Variables
👨💼 Great job! You've learned how to store values in variables.
🦉 Here's when to use each:
- Use
constwhen you know the value won't need to change. This is the default choice for most variables. - Use
letwhen you need to reassign the value later (like a counter or a value that updates).
A common mistake is trying to reassign a
const:const greeting = 'Hello'
greeting = 'Hi' // ❌ Error! Can't reassign a constant
When in doubt, start with
const. You can always change it to let if you need
to reassign it later.