Skip to content

Commit 12ffb37

Browse files
committed
completed constructors mini
1 parent f2f21a8 commit 12ffb37

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎constructors.js‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ function Animal(options) {
99
}
1010

1111
// add 'grow' to Animal's prototype here
12+
Animal.prototype.grow = function () {
13+
console.log(`${this.name} grew larger`);
14+
}
1215

1316
// problem #2
1417
// setup Cat to inherit from Animal
@@ -18,16 +21,17 @@ function Animal(options) {
1821

1922
function Cat(options) {
2023
// invoke Animal here with .call
24+
Animal.call(this, options);
2125
}
2226

2327
// connect the prototypes here
24-
28+
Cat.prototype = Object.create(Animal.prototype);
2529
// if everything is setup properly the code below will print 'Foofie grew larger!'
2630
// uncomment the code below to test your solution
2731

28-
// const foofie = new Cat({
29-
// name: 'foofie',
30-
// });
31-
//
32-
// foofie.grow();
32+
const foofie = new Cat({
33+
name: 'foofie',
34+
});
35+
36+
foofie.grow();
3337

0 commit comments

Comments
 (0)