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
and:
- Create a
constnamedTAX_RATEset to0.08 - Create a
letnamedcartTotalstarting at0 - Create
constproduct prices with these exact values:bookPrice=15.99muffinPrice=4.5laptopPrice=999.99
- Add the book and the muffin to the cart by updating
cartTotal(do not add the laptop for this step) - Create
finalTotalas the cart subtotal plus 8% tax (TAX_RATE) - Try to reassign
TAX_RATE(keep it commented after you see the TypeScript error) and export your results
Required exports
Export these names so the tests can verify your work:
TAX_RATEcartTotalfinalTotal
Completion criteria (with the fixtures above)
TAX_RATEis0.08cartTotalis20.49(book + muffin only)finalTotalis22.1292(subtotal + 8% tax)
π° 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.


