Skip to content
Open
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
6,165 changes: 5,165 additions & 1,000 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
"repository": {
"type": "git",
"url": "git+https://github.com/LambdaSchool/javascript-ii.git"
},
},
"devDependencies": {
"babel-jest": "^19.0.0",
"eslint": "^3.17.1",
"eslint-config-airbnb-base": "^11.1.3",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-import": "^2.9.0",
"jest": "^19.0.2",
"regenerator-runtime": "^0.10.3"
},
"dependencies": {
"babel-preset-es2015": "^6.24.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0",
"eslint-plugin-react": "6.9.0"
"eslint-plugin-react": "6.9.0",
"jest-cli": "^22.4.3"
}
}
30 changes: 30 additions & 0 deletions src/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
// 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(somePassword) {
return somePassword === this.password;
}
}

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

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

Choose a reason for hiding this comment

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

this function won't actually affect your animal age.
temp needs to be this.age

}

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

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

/* eslint-disable no-undef */

Expand Down
34 changes: 34 additions & 0 deletions src/prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,40 @@

/* eslint-disable no-undef */

function GameObject(object) {
this.createdAt = object.createdAt;
this.dimensions = object.dimensions;
}

GameObject.prototype.destroy = function () {
return 'Game object was removed from the game.';
};

function NPC(nonPlay) {
GameObject.call(this, nonPlay);
this.hp = nonPlay.hp;
this.name = nonPlay.name;
}

NPC.prototype = Object.create(GameObject.prototype);

NPC.prototype.takeDamage = function () {
return `${this.name} took damage.`;
};

function Humanoid(human) {
NPC.call(this, human);
this.faction = human.faction;
this.weapons = human.weapons;
this.language = human.language;
}

Humanoid.prototype = Object.create(NPC.prototype);

Humanoid.prototype.greet = function () {
return `${this.name} offers a greeting in ${this.language}.`;
};

module.exports = {
GameObject,
NPC,
Expand Down
11 changes: 11 additions & 0 deletions src/recursion.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
const nFibonacci = (n) => {
// fibonacci sequence: 1 1 2 3 5 8 13 ...
// return the nth number in the sequence
return n < 2 ? n : nFibonacci(n - 1) + nFibonacci(n - 2);
};

// other solve from solution code which is diff from what mine looks like so wanted to save for referece:
// const nFibonacci = (n) => {
// // fibonacci sequence: 1 2 3 5 8 13 ...
// // return the nth number in the sequence
// if (n < 2) return 1;
// return nFibonacci(n - 1) + nFibonacci(n - 2);
// };

const nFactorial = (n) => {
// factorial example: !5 = 5 * 4 * 3 * 2 * 1
// return the factorial of `n`
if (n <= 1) return 1;
return n * nFactorial(--n);
};

/* Extra Credit */
Expand Down
16 changes: 14 additions & 2 deletions src/this.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

class User {
constructor(options) {
this.username = options.username;
this.password = options.password;
// set a username and password property on the user object that is created
}
checkPassword(passwordToCompare) {
return this.password === passwordToCompare;
}
// create a method on the User class called `checkPassword`
// this method should take in a string and compare it to the object's password property
// return `true` if they match, otherwise return `false`
Expand All @@ -16,24 +21,31 @@ class User {
const me = new User({
username: 'LambdaSchool',
password: 'correcthorsebatterystaple',
checkPassword(passwordToCompare) {
return this.password === passwordToCompare;
},
});

const result = me.checkPassword('correcthorsebatterystaple'); // should return `true`


/* part 2 */

const checkPassword = function comparePasswords(passwordToCompare) {
// recreate the `checkPassword` method that you made on the `User` class
// use `this` to access the object's `password` property.
// do not modify this function's parameters
// note that we use the `function` keyword and not `=>`
return Object.prototype.call(User.checkPassword).apply(passwordToCompare);
};

// invoke `checkPassword` on `me` by explicitly setting the `this` context
// use .call, .apply, and .bind

// .call

checkPassword.call(me, 'correcthorsebatterystaple');
// .apply

checkPassword.apply(me, 'correcthorsebatterystaple');
// .bind
const boundPasswordCheck = checkPassword.bind(me);
boundPasswordCheck('correcthorsebatterystaple');
65 changes: 65 additions & 0 deletions yarn-error.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Arguments:
C:\Program Files\nodejs\node.exe C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js i

PATH:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Users\kaitl\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\Microsoft VS Code\bin;C:\Users\kaitl\AppData\Roaming\npm

Yarn version:
1.5.1

Node version:
8.9.4

Platform:
win32 x64

npm manifest:
{
"name": "javascript-ii",
"version": "1.0.0",
"description": "JavaScript II",
"main": "index.js",
"scripts": {
"test": "eslint tests/*.test.js && eslint src/*.js && jest --verbose",
"test:watch": "npm test -- --watch"
},
"author": "Ben Nelson",
"license": "ISC",
"repository": {
"type": "git",
"url": "git+https://github.com/LambdaSchool/javascript-ii.git"
},
"devDependencies": {
"babel-jest": "^19.0.0",
"eslint": "^3.17.1",
"eslint-config-airbnb-base": "^11.1.3",
"eslint-plugin-import": "^2.2.0",
"jest": "^19.0.2",
"regenerator-runtime": "^0.10.3"
},
"dependencies": {
"babel-preset-es2015": "^6.24.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-jsx-a11y": "^3.0.2 || ^4.0.0",
"eslint-plugin-react": "6.9.0"
}
}

yarn manifest:
No manifest

Lockfile:
No lockfile

Trace:
Error: Command "i" not found.
at new MessageError (C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:186:110)
at C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:87307:17
at Generator.next (<anonymous>)
at step (C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:98:30)
at C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:116:14
at new Promise (<anonymous>)
at new F (C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:23451:28)
at C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:95:12
at runCommand (C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:87312:22)
at Object.<anonymous> (C:\Users\kaitl\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:87412:14)
Loading