File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ // to test these problems you can run 'node classes.js' in your terminal
2+
3+ // problem #1
4+ // convert the Animal constructor function from 'constructors.js' into an ES6 class
5+
6+
7+ // problem #2
8+ // convert the Cat constructor function from 'constructors.js' into an ES6 class
9+
10+
11+ // if everything is setup properly the code below will print 'Foofie grew larger!'
12+ // uncomment the code below to test your solution
13+
14+ // const foofie = new Cat({
15+ // name: 'foofie',
16+ // });
17+ //
18+ // foofie.grow();
19+
Original file line number Diff line number Diff line change 1+ // to test these problems you can run 'node constructors.js' in your terminal
2+
3+ // problem #1
4+ // add a method to Animal's prototype called 'grow'
5+ // when 'grow' is invoked log '<name> grew larger!'
6+
7+ function Animal ( options ) {
8+ this . name = options . name ;
9+ }
10+
11+ // add 'grow' to Animal's prototype here
12+
13+ // problem #2
14+ // setup Cat to inherit from Animal
15+ // the Animal constructor needs to be invoked with the 'options' argument
16+ // Cat should have its prototype inherit from Animal
17+ // instances of Cat should also have access to the 'grow' method
18+
19+ function Cat ( options ) {
20+ // invoke Animal here with .call
21+ }
22+
23+ // connect the prototypes here
24+
25+ // if everything is setup properly the code below will print 'Foofie grew larger!'
26+ // uncomment the code below to test your solution
27+
28+ // const foofie = new Cat({
29+ // name: 'foofie',
30+ // });
31+ //
32+ // foofie.grow();
33+
You can’t perform that action at this time.
0 commit comments