Spot the bug in Cart items

from Objects and prototypes
Node 24 intermediate 4 min 1 issue to find

Find why adding an item to one cart changes the other cart.

JavaScript
function Cart() {}
Cart.prototype.items = [];
Cart.prototype.add = function add(item) {
  this.items.push(item);
};

const first = new Cart();
const second = new Cart();
first.add('book');
console.log(second.items);
Open in playground
Report an error