8000 updates to instructions · Steverenner1/JavaScript-IV@064e39d · GitHub
[go: up one dir, main page]

Skip to content

Commit 064e39d

Browse files
committed
updates to instructions
1 parent 04f8e3b commit 064e39d

File tree

3 files changed

+23
-87
lines changed

3 files changed

+23
-87
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const fred = new Person({
2727

2828
## `prototype-refactor` - Take existing code and make it modern.
2929

30-
* You're going to work with your prototypes assignment you built out yesterday. Only this time you're going to actually have a solution built out for you.
30+
* You're going to work with your prototypes assignment you built out yesterday.
3131
* `Challenge:` **Convert** all of your constructors into ES6 Classes using the `class` and `extends` keywords. You should be able to run your same logs and they should build out the proper expected behaviors.
3232

3333
## `lambda-classes` - We need a roster of Lambda School personnel. Build it!

assignments/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
8+
<title>JS IV</title>
9+
10+
<script src="prototype-refactor.js"></script>
11+
<script src="lambda-classes.js"></script>
12+
</head>
13+
14+
<body>
15+
<h1>JS IV - Check your work in the console!</h1>
16+
</body>
17+
</html>

assignments/prototype-refactor.js

Lines changed: 5 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,9 @@
1-
// Here we have a functioning solutoin to your challenge from yesterday.
2-
// Today your goal is to refactor all of this code to use ES6 Classes.
3-
// The console.log() statements should still return what is expected of them.
1+
/*
42
5-
function GameObject(options) {
6-
this.createdAt = options.createdAt;
7-
this.dimensions = options.dimensions;
8-
}
3+
Prototype Refactor
94
10-
GameObject.prototype.destroy = function() {
11-
return `Object was removed from the game.`;
12-
};
5+
1. Copy and paste your code or the solution from yesterday
136
14-
function CharacterStats(characterStatsOptions) {
15-
GameObject.call(this, characterStatsOptions);
16-
this.hp = characterStatsOptions.hp;
17-
this.name = characterStatsOptions.name;
18-
}
7+
2. Your goal is to refactor all of this code to use ES6 Classes. The console.log() statements should still return what is expected of them.
198
20-
CharacterStats.prototype = Object.create(GameObject.prototype);
21-
22-
CharacterStats.prototype.takeDamage = function() {
23-
return `${this.name} took damage.`;
24-
};
25-
26-
function Humanoid(humanoidOptions) {
27-
CharacterStats.call(this, humanoidOptions);
28-
this.faction = humanoidOptions.faction;
29-
this.weapons = humanoidOptions.weapons;
30-
this.language = humanoidOptions.language;
31-
}
32-
33-
Humanoid.prototype = Object.create(CharacterStats.prototype);
34-
35-
Humanoid.prototype.greet = function() {
36-
return `${this.name} offers a greeting in ${this.language}.`;
37-
};
38-
39-
const mage = new Humanoid({
40-
createdAt: new Date(),
41-
dimensions: {
42-
length: 2,
43-
widt ED4F h: 1,
44-
height: 1
45-
},
46-
hp: 5,
47-
name: 'Bruce',
48-
faction: 'Mage Guild',
49-
weapons: ['Staff of Shamalama'],
50-
language: 'Common Toungue'
51-
});
52-
53-
const swordsman = new Humanoid({
54-
createdAt: new Date(),
55-
dimensions: {
56-
length: 2,
57-
width: 2,
58-
height: 2
59-
},
60-
hp: 15,
61-
name: 'Sir Mustachio',
62-
faction: 'The Round Table',
63-
weapons: ['Giant Sword', 'Shield'],
64-
language: 'Common Toungue'
65-
});
66-
67-
const archer = new Humanoid({
68-
createdAt: new Date(),
69-
dimensions: {
70-
length: 1,
71-
width: 2,
72-
height: 4
73-
},
74-
hp: 10,
75-
name: 'Lilith',
76-
faction: 'Forest Kingdom',
77-
weapons: ['Bow', 'Dagger'],
78-
language: 'Elvish'
79-
});
80-
81-
console.log(mage.createdAt); // Today's date
82-
console.log(archer.dimensions); // { length: 1, width: 2, height: 4 }
83-
console.log(swordsman.hp); // 15
84-
console.log(mage.name); // Bruce
85-
console.log(swordsman.faction); // The Round Table
86-
console.log(mage.weapons); // Staff of Shamalama
87-
console.log(archer.language); // Elvish
88-
console.log(archer.greet()); // Lilith offers a greeting in Elvish.
89-
console.log(mage.takeDamage()); // Bruce took damage.
90-
console.log(swordsman.destroy()); // Sir Mustachio was removed from the game.
9+
*/

0 commit comments

Comments
 (0)
0