My code does not work correctly, I can not understand why. when you transfer the card to the shoop, he does not add money to it
function Card (money=0) {
this.money = money;
}
Card.prototype.addMoney = function(mon) {
return this.money=this.money+mon;
}
function CreditCard (money =0) {
this.money = money;
}
CreditCard.prototype = Object.create(Card.prototype);
function Shop (card) {
this.card = card
this.money=card.money;
this.addMoney=this.card.addMoney;
}
Shop.prototype = Object.create(Card.prototype);
let card1 = new CreditCard(50);
card1.addMoney(10);//60
card1.addMoney(10);//70
let card2 = new Card(250);
let shop1 = new Shop(card1);
shop1.addMoney(10);//80 but don't work
console.log(card1.money);