const atTheOldToad = {
potions: [
{ name: 'Зелье скорости', price: 460 },
{ name: 'Дыхание дракона', price: 780 },
{ name: 'Каменная кожа', price: 520 },
],
// Пиши код ниже этой строки
getPotions() {
return this.potions;
},
addPotion(potionName) {
if (this.potions.includes(potionName)) {
return Зелье ${potionName} уже есть в инвентаре!;
}
this.potions.push(potionName);
},
removePotion(potionName) {
const potionIndex = this.potions.indexOf(potionName);
if (potionIndex === -1) {
return Зелья ${potionName} нет в инвентаре!;
} else{
this.potions.splice(potionIndex, 1);
}
},
updatePotionName(oldName, newName) {
const potionIndex = this.potions.indexOf(oldName);
if (potionIndex === -1) {
return Зелья ${oldName} нет в инвентаре!;
}
this.potions.splice(potionIndex, 1, newName);
},
// Пиши код выше этой строки
};
// console.log();
//atTheOldToad.addPotion({ name: 'Невидимка', price: 620 })
//console.log(atTheOldToad.getPotions());
atTheOldToad.removePotion('Дыхание дракона')
console.log(atTheOldToad.getPotions());