Skip to content

Commit 1daea57

Browse files
committed
completed classes.js
1 parent 74be899 commit 1daea57

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

‎classes.js‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,29 @@
22

33
// problem #1
44
// convert the Animal constructor function from 'constructors.js' into an ES6 class
5-
5+
class Animal {
6+
constructor(options) {
7+
this.name = options.name;
8+
}
9+
grow() {
10+
console.log(`${this.name} grew larger!`);
11+
}
12+
}
613

714
// problem #2
815
// convert the Cat constructor function from 'constructors.js' into an ES6 class
9-
16+
class Cat extends Animal {
17+
constructor(options) {
18+
super(options);
19+
}
20+
}
1021

1122
// if everything is setup properly the code below will print 'Foofie grew larger!'
1223
// uncomment the code below to test your solution
1324

14-
// const foofie = new Cat({
15-
// name: 'foofie',
16-
// });
17-
//
18-
// foofie.grow();
25+
const foofie = new Cat({
26+
name: 'Foofie',
27+
});
28+
29+
foofie.grow();
1930

0 commit comments

Comments
 (0)