JavaScript Override inherited methods

Tell us what’s happening:

There’s error “cannot read property prototype undefined”
Plz explain what I’m doing wrong

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 (Linux; Android 5.1; Lenovo P1ma40) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.99 Mobile Safari/537.36.

Challenge: Override Inherited Methods

Link to the challenge:

Hi,

It’s because you have put penguin without a capital but the object has a capital P
:smiley:

1 Like

Hey thanks for answering!
I have another question .
Did you use to make mistakes like this when you were learning?

Hi there,

Yes all the time.
I still do, it is very common.
It sometimes takes me hours looking through my code that isn’t working just because of one spelling mistake :smiley:

1 Like

I’ve been doing this professionally for almost a decade and I still make those mistakes. I’ve just gotten better at finding them (mostly because I’ve made them so many times).
image

1 Like