Let and Const

Let and Const
πŸ‘¨β€πŸ’Ό We're building a shopping cart system. Some values will change as users interact (like the cart total), while others stay constant (like tax rates and product prices).
🐨 Open
index.ts
and:
  1. Create a const for TAX_RATE set to 0.08
  2. Create a let for cartTotal starting at 0
  3. Create const variables for product prices: bookPrice, muffinPrice, and laptopPrice
  4. Add items to the cart by updating cartTotal
  5. Try to reassign TAX_RATE and see what TypeScript says
πŸ’° By convention, constants that represent fixed values are often UPPER_CASE:
const MAX_ITEMS = 100
const API_URL = 'https://api.example.com'
πŸ“œ MDN - const
This is the first exercise where you'll be exporting values for the tests! For a reminder on how to do that, check out the previous page.

Please set the playground first

Loading "Let and Const"
Loading "Let and Const"