A little question about this phase - Object Oriented Programming - Change the Prototype to a New Object

Hi Everyone,

I have a question about the object programming.
While using the code below, it seems that i can’t access the function through the beagle object.
How can i use the function that i just added in the object prototype (Bird.prototype) ?

I just started to deep dive into this,

Your code so far

class Bird {
    constructor(name, age, color, personnality) {
        this.name = name;
        this.age = age;
        this.color = color;
        this.personnality = personnality;
    }
}

console.log(Bird); 

Bird.prototype = {
    numLegs: 4,
    eat() {
      return "je bouffe des chocolat"
    },
    describe() {
      console.log(`Je décris la personnalité de ${this.name}`)
    }
  
  };

console.log(Bird.prototype.eat)

Thanks,
Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: Object Oriented Programming - Change the Prototype to a New Object

Link to the challenge:

const parrot = new Bird('Bob', '13', 'blue', 'exhuberant');

now you can do parrot.eat() and parrot.describe()

Alright, thanks for the information !

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.