Конструктор не возвращает метод - PullRequest
0 голосов
/ 18 октября 2018

Я получаю catchPhrase не является функцией.Я пытаюсь выяснить, почему это не ведение журнала. Когда я использую другие методы, включенные в мой код, он работает, но этот конкретный не работает.

function Humanoid(humanoidAtts) {
  GameObject.call(this, humanoidAtts);
  CharacterStats.call(this, humanoidAtts);
  this.faction = humanoidAtts.faction;
  this.weapons = humanoidAtts.weapons;
  this.language = humanoidAtts.language;
}

Humanoid.prototype = Object.create(CharacterStats.prototype)

Humanoid.prototype.greet = function(){
  return `${this.name} offers a greeting in ${this.language}`
}

 function Hero(heroAtts) {
   Humanoid.call(this, heroAtts);
 }

 Hero.prototype = Object.create(GameObject.prototype);
 Hero.prototype = Object.create(CharacterStats.prototype);
 Hero.prototype = Object.create(Humanoid.prototype);

 Hero.prototype.catchPhrase = function(){
  return `${this.name} says, look you got blood on my dress`
}

Герой определендальше.

const hero =  new Humanoid ({
  createdAt: new Date(),
  dimensions: {
    length: 3,
    width: 2,
    height: 5,
  },
  hp: 20,
  name: 'Bouncing Betty',
  faction: 'Tot Land',
  weapons: [
    'Parasol',
    'Tessen',
  ],
  language: 'Tabaxi',
});

console.log(hero.catchPhrase());
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...