prototype help fixes
//Now the test pass. Here is what I found.
//there was a typo in the name of the properties
//dimentions -> instead dimensions
function GameObject(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}
//For some reason this test gives a warning when
// we write GameObject.prototype.destroy = function () {
//instead: GameObject.prototype.destroy = function destroy() {
GameObject.prototype.destroy = function destroy() {
return ('Game object was removed from the game.');
};
function NPC(npcOptions) {
GameObject.call(this, npcOptions);
this.hp = npcOptions.hp;
this.name = npcOptions.name;
}
//Here as the other functions you were passing a aparam to takeDamage
//you shouldn't since there is nothing to pass.
NPC.prototype = Object.create(GameObject.prototype);
NPC.prototype.takeDamage = function takeDamage() {
return (`${this.name} took damage.`);
};
function Humanoid(humanOptions) {
NPC.call(this, humanOptions);
this.faction = humanOptions.faction;
this.weapons = humanOptions.weapons;
this.language = humanOptions.language;
}
//Here you had the return between parentesis
//also you miss the dot at the end so that produce a missmatch in the test.
Humanoid.prototype = Object.create(NPC.prototype);
Humanoid.prototype.greet = function greet() {
return `${this.name} offers a greeting in ${this.language}.`;
};
const hamsterHuey = new Humanoid({
createdAt: new Date(),
dimensions: {
length: 2,
width: 1,
height: 1,
},
hp: 5,
name: 'Hamster Huey',
faction: 'Gooey Kablooie',
weapons: [
'bubblegum',
],
language: 'Hamsterish',
});
hamsterHuey.greet();
hamsterHuey.takeDamage();
hamsterHuey.destroy();