I have a constructor for parent:
function genshinImpactCharacter(weapon, vision, rarity) {
this.weapon = weapon;
this.vision = vision;
this.rarity = rarity;
}
Later I create an object with the new keyword:
const Sucrose = new genshinImpactCharacter('Catalyst', 'Anemo', 4);
I am trying to use defineProperty to add property favFlower: "Sweet Flower"
Object.defineProperty(Sucrose, "favFlower", {
name: 'Sweet Flower',
});
However, when I am trying to access favFlower, it returns undefined. As well, when I print the whole object in the console, this property remains undefined.
Where did I make the mistake?
weaponetc can be, why not just doSucrose.favFlower = 'Sweet Flower'??