my apologies if this question has been answered in previous post. I looked but found nothing like it. I am wondering if anyone knows of a way that I can add a key to a resulting object from a factory function. Meaning, outside of the factory function I want to later add a key versus going back to the factory function itself and changing what the out put should be.
/*below you will see where I have tried to add the key from the outside using the function name as the object name similiar to how one would with a standard object but the code below will return undefinded, my guess is because the object has no name, but rather is simply returned.*/
function createCharacter(name, nick, race, origin, attack, defense){
return {
name: name,
nickname: nick,
race: race,
origin: origin,
attack: attack,
defense: defense,
describe: function(){
console.log(`${this.name} is a ${this.race} from ${this.origin}`);
}
}
createCharacter.weapon = weapon;