forked from bloominstituteoftechnology/JavaScript-II-Mini
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.js
More file actions
32 lines (27 loc) · 794 Bytes
/
classes.js
File metadata and controls
32 lines (27 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// to test these problems you can run 'node classes.js' in your terminal
// problem #1
// convert the Animal constructor function from 'constructors.js' into an ES6 class
// function Animal(options) {
// this.name = options.name;
class Animal {
constructor (options) {
this.name = options.name;
}
grow () {
return (`${this.name} grew larger!`);
}
}
// problem #2
// convert the Cat constructor function from 'constructors.js' into an ES6 class
class Cat extends Animal {
constructor(options) {
super(options);
}
}
// if everything is setup properly the code below will print 'Foofie grew larger!'
// uncomment the code below to test your solution
const ravioli = new Cat({
name: 'Ravioli',
});
//
console.log(ravioli.grow());