Skip to content

Commit bd092c9

Browse files
finished class.js
1 parent bad0637 commit bd092c9

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

src/class.js

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

1010
// code here
1111

12+
class User {
13+
constructor(options) {
14+
this.email = options.email;
15+
this.password = options.password;
16+
}
17+
comparePasswords(testPassword) {
18+
if (this.password === testPassword) {
19+
return true;
20+
}
21+
return false;
22+
}
23+
}
24+
25+
// const cruise = new User({
26+
// email: '[email protected]',
27+
// password: 'correcthorsebatterystaple',
28+
// });
29+
30+
// console.log(cruise.comparePasswords('correcthorsebatterystaple'));
31+
1232
// Part 2
1333
// Create a class called `Animal` and a class called `Cat` using ES6 classes.
1434
// `Cat` should extend the `Animal` class.
@@ -21,6 +41,34 @@
2141

2242
// code here
2343

44+
class Animal {
45+
constructor(options) {
46+
this.age = options.age;
47+
}
48+
growOlder() {
49+
this.age++;
50+
return this.age;
51+
}
52+
}
53+
54+
class Cat extends Animal {
55+
constructor(options) {
56+
super(options);
57+
this.name = options.name;
58+
}
59+
meow() {
60+
return `${this.name} meowed!`;
61+
}
62+
}
63+
64+
// const finn = new Cat({
65+
// name: 'Finn',
66+
// age: 2,
67+
// });
68+
69+
// console.log(finn.growOlder());
70+
// console.log(finn.meow());
71+
2472
/* eslint-disable no-undef */
2573

2674
module.exports = {

0 commit comments

Comments
 (0)