challenges

Copycat object

Moxie and Gus start out with the same number of toys. But then Gus starts stealing from Moxie (he’s cute but a bit of a toy hog). Unfortunately, this code doesn’t keep track of the toy counts as expected. What’s the issue?

Code with error

const moxieToyCounts = {
  mice: 4,
  feathers: 3,
  hairTies: 25,
};
 
const gusToyCounts = moxieToyCounts;
 
// gus steals a feather
gusToyCounts.feathers += 1;
moxieToyCounts.feathers -= 1;
 
// this should be reflected in the toy counts...
//   ...but it's not
console.log(gusToyCounts.feathers) // 3
console.log(moxieToyCounts.feathers) // 3