Intermediate · Unit 3 · Lesson 18
References and Mutation
- Start
- Learn
- Practice
- Step through
- On your own
StartWhat you'll be able to read
const cart = { items: ["mug"] };const badgeCart = cart;cart.items.push("tee");console.log(badgeCart.items.length);The program you'll be able to read
A store's header badge and its cart page use the same cart. Line 4 adds to cart; no line ever changes badgeCart. By the end of this lesson you'll know what line 6 prints, and why.
One idea at a time: watch an example run line by line, try a near-copy, then one on your own.

