File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ 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.
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
2674module . exports = {
You can’t perform that action at this time.
0 commit comments