Skip to content

Commit 575fffe

Browse files
committed
completed class.js
1 parent aaaaadc commit 575fffe

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/class.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@
99

1010
// code here
1111

12+
class User {
13+
constructor(options) {
14+
this.email = options.email;
15+
this.password = options.password;
16+
}
17+
18+
// method comparePasswords() for User class
19+
comparePasswords(passwords) {
20+
if (this.password === passwords) {
21+
return true;
22+
}
23+
return false;
24+
}
25+
}
26+
1227
// Part 2
1328
// Create a class called `Animal` and a class called `Cat` using ES6 classes.
1429
// `Cat` should extend the `Animal` class.
@@ -21,6 +36,28 @@
2136

2237
// code here
2338

39+
class Animal {
40+
constructor(options) {
41+
this.age = options.age;
42+
}
43+
44+
// Animal method growOlder()
45+
growOlder() {
46+
return this.age + 1;
47+
}
48+
}
49+
50+
class Cat extends Animal {
51+
constructor(options) {
52+
super(options);
53+
this.name = options.name;
54+
}
55+
56+
meow() {
57+
return `${this.name} meowed!`;
58+
}
59+
}
60+
2461
/* eslint-disable no-undef */
2562

2663
module.exports = {

0 commit comments

Comments
 (0)