Object Oriented Programming: Override Inherited Methods

Tell us what’s happening:
I do not understand what is the reason why I cannot override the method fly of Bird.
I am trying to override it by making a new method in Penguin.

Your code so far


function Bird() { }

Bird.prototype.fly = function() { return "I am flying!"; };


function Penguin() { }
Penguin.prototype = Object.create(Bird.prototype);
Penguin.prototype.constructor = Penguin;

// Only change code below this line

Penguin.prototype.fly=function (){
return"Alas, this is a flightless bird";
};



// Only change code above this line

let penguin = new Penguin();
console.log(penguin.fly());

Your browser information:

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

Challenge: Override Inherited Methods

Link to the challenge:

You are correctly overriding the fly() method of Bird. You are not returning the correct string. Also, you want to put a space between return and the string.

1 Like

I was not using the dot either

1 Like

Did you answer it?
You are not adding the bird variable either.

1 Like

Yes, thanks for asking. I have done it <3.

1 Like