Nie wiem nawet jak się za to zabrać
const atTheOldToad = {
potions: [
{ name: "Speed potion", price: 460 }, // obiekt 1
{ name: "Dragon breath", price: 780 }, // obiekt 2
{ name: "Stone skin", price: 520 }, // obiekt 3
],
getPotions() {
return this.potions;
},
addPotion(newPotion) {
if (this.potions.includes(newPotion)) {
return `Error! Potion ${newPotion} is already in your inventory!`;
}
this.potions.push(newPotion);
},
removePotion(potionName) {
const potionIndex = this.potions.indexOf(potionName);
if (potionIndex === -1) {
return `Potion ${potionName} is not in inventory!`;
}
this.potions.splice(potionIndex, 1);
},
updatePotionName(oldName, newName) {
const potionIndex = this.potions.indexOf(oldName);
if (potionIndex === -1) {
return `Potion ${oldName} is not in inventory!`;
}
this.potions.splice(potionIndex, 1, newName);
},
};