Skip to content

Commit 57ce5ba

Browse files
committed
Prototypal inheritance tests passing
1 parent 453c499 commit 57ce5ba

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

topics/about_prototypal_inheritance.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ $(document).ready(function(){
88
// this 'class' pattern defines a class by its constructor
99
var Mammal = function(name) {
1010
this.name = name;
11-
}
11+
};
1212
// things that don't need to be set in the constructor should be added to the constructor's prototype property.
1313
Mammal.prototype = {
1414
sayHi: function() {
1515
return "Hello, my name is " + this.name;
1616
}
17-
}
17+
};
1818

1919
test("defining a 'class'", function() {
2020
var eric = new Mammal("Eric");
21-
equals(eric.sayHi(), __, 'what will Eric say?');
21+
equals(eric.sayHi(), "Hello, my name is Eric", 'what will Eric say?');
2222
});
2323

2424
// add another function to the Mammal 'type' that uses the sayHi function
2525
Mammal.prototype.favouriteSaying = function() {
2626
return this.name + "'s favourite saying is " + this.sayHi();
27-
}
27+
};
2828

2929
test("more functions", function() {
3030
var bobby = new Mammal("Bobby");
31-
equals(bobby.favouriteSaying(), __, "what is Bobby's favourite saying?");
31+
equals(bobby.favouriteSaying(), "Bobby's favourite saying is Hello, my name is Bobby", "what is Bobby's favourite saying?");
3232
});
3333

3434
test("calling functions added to a prototype after an object was created", function() {
@@ -37,7 +37,7 @@ $(document).ready(function(){
3737
return this.name.length;
3838
};
3939
// for the following statement asks the paul object to call a function that was added to the Mammal prototype after paul was constructed.
40-
equals(paul.numberOfLettersInName(), __, "how long is Paul's name?");
40+
equals(paul.numberOfLettersInName(), 4, "how long is Paul's name?");
4141
});
4242

4343
// helper function for inheritance.
@@ -57,8 +57,8 @@ $(document).ready(function(){
5757

5858
test("Inheritance", function() {
5959
var lenny = new Bat("Lenny", "1.5m");
60-
equals(lenny.sayHi(), __, "what does Lenny say?");
61-
equals(lenny.wingspan, __, "what is Lenny's wingspan?");
60+
equals(lenny.sayHi(), "Hello, my name is Lenny", "what does Lenny say?");
61+
equals(lenny.wingspan, "1.5m", "what is Lenny's wingspan?");
6262
});
6363

6464

0 commit comments

Comments
 (0)