-
Notifications
You must be signed in to change notification settings - Fork 11
Prototypes class1 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| expected = Reptile.SOUND; | ||
| actual = reptile.speak(); | ||
| test.equal( actual, expected, 'should make a reptile sound when it speaks' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is failing but I don't understand why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is failing because you said this.SOUND in your constructor, where this refers to the "instance" of the reptile, whereas Reptile does not refer to the instance but to the constructor. Does that difference make sense?
As a first hint, if you can access it via Reptile.SOUND, how might you set it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha! Its should be expected = reptile.SOUND
joshdmiller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got the structure right; check out my response to your question. But you're getting it! 👍
|
|
||
| expected = Reptile.SOUND; | ||
| actual = reptile.speak(); | ||
| test.equal( actual, expected, 'should make a reptile sound when it speaks' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is failing because you said this.SOUND in your constructor, where this refers to the "instance" of the reptile, whereas Reptile does not refer to the instance but to the constructor. Does that difference make sense?
As a first hint, if you can access it via Reptile.SOUND, how might you set it?
|
|
||
| Reptile.prototype = Object.create(Animal.prototype) | ||
| export class Reptile extends Animal { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain what super does in the next class.
No description provided.