Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
// Return true if the potential password matches the `password` property. Otherwise return false.

// code here
class User {
constructor(options) {
this.email = options.email;
this.password = options.password;
}
comparePasswords(potentialPassword) {
if (potentialPassword === this.password) return true;
return false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this with one line return potentialPassword === this.password

}
}

// Part 2
// Create a class called `Animal` and a class called `Cat` using ES6 classes.
Expand All @@ -20,6 +30,23 @@
// property set on the Cat instance.

// code here
class Animal {
constructor(options) {
this.age = options.age;
}
growOlder() {
return this.age;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to increment the age with growOlder()

}
}

class Cat extends Animal {
super(options) {
this.name = options.name;
}
meow() {
return `${this.name} meowed!`;
}
}

/* eslint-disable no-undef */

Expand Down
7 changes: 7 additions & 0 deletions src/prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
hamsterHuey.takeDamage(); // returns 'Hamster Huey took damage.'
hamsterHuey.destroy(); // returns 'Game object was removed from the game.'
*/
function GameObject(options) {
this.createdAt = options.createdAt;
this.dimensions = options.dimensions;
}
GameObject.prototype.destroy = function() {
return 'Game object was removed from the game.';
};

/* eslint-disable no-undef */

Expand Down