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
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@

## Topics

* recursion
* base case
* constructors
* `new`
* `prototype`
* `.bind`, `.call`, `.apply`
* `this`
* `class`
* methods
* inheritance
* prototype methods vs methods in the constructor (Methods that inherit via the prototype chain can be changed universally for all instances)
* class vs instance
* recursion - when it function calls itself until it doesn't
* base case - a "stopper" solution that has a known solution that returns out of the function.
* constructors - functions that create objects of the same type with set variables.
* `new`- keyword used to create an instance of an object
* `prototype` - All objects inherit properties and methods from the prototype that it sits upon.
<<<<<<< HEAD
* `.bind` - returns a copy of the function and forces the function to reference the object where it's bound to.
*`.call` - allows you to call a function by an ojbect outside of another object passing the other object as an arugment
*`.apply`
* `this` - refers to the context where the function is being call and refers to that object
<<<<<<< HEAD
* `class` - a blueprint for objects that has properties and methods.
* methods - Is a function that belongs to a class
* inheritance - when a class extends another class and gets access to the properties and methods of the parent
* prototype methods vs methods in the constructor (Methods that inherit via the prototype chain can be changed universally for all instances) Prototype allows you to add methods to already existing objects, while the constructor methods are made on new objects when they are instianated.
* class vs instance - class methods require an object to be made from the class adn the method is ran on each instantiation depending on which one calls it, while static is associatd with the class and does not need an instantion.
=======



## Instructions
Expand Down
165 changes: 148 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/LambdaSchool/javascript-ii.git"
},
},
"devDependencies": {
"babel-jest": "^19.0.0",
"eslint": "^3.17.1",
Expand Down
30 changes: 30 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) {
return potentialPassword === this.password;
}
}

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

// code here
class Animal {
constructor(options) {
this.age = options.age;
}

growOlder() {
return this.age + 1;
}
}

class Cat extends Animal {
constructor(options) {
super(options);
this.name = options.name;
}

meow() {
return `${this.name} meowed!`;
}
}

/* eslint-disable no-undef */

Expand Down
Loading