Break Variables
👨💼 Great job understanding the difference between
let and const!Key takeaways:
- 🔒
constprevents reassignment—use it by default - 🔄
letallows reassignment—use for values that change - ⚠️
constdoesn't prevent mutation—objects and arrays can still be modified
🦉 A good rule of thumb: Start with
const. If you find you need to reassign,
change it to let. This makes your intentions clear to anyone reading your
code.The distinction between reassignment and mutation becomes even more important
when working with objects and arrays, which we'll cover in the next workshop.
Next up: Primitive Types—adding type annotations for extra safety!
Test Your Knowledge
Retrieval practice helps solidify learning by actively recalling information. Use this prompt with your AI assistant to quiz yourself on what you've learned.
Please quiz me on exercise 2 using the epicshop MCP server. Call the get_quiz_instructions tool with exerciseNumber "2" to get the quiz instructions, then quiz me one question at a time.