-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathprototype-refactor.js
More file actions
86 lines (71 loc) · 2.11 KB
/
Copy pathprototype-refactor.js
File metadata and controls
86 lines (71 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
Prototype Refactor
1. Copy and paste your code or the solution from yesterday
function GameObject(video) {
this.createdAt = video.createdAt;
this.name = video.name;
this.dimensions = video.dimensions;
}
GameObject.prototype.destroy = function() {
return `${this.name} was removed from the game.`;
};
function CharacterStats(attribute) {
GameObject.call(this,attribute);
this.healthPoints = attribute.healthPoints;
}
//This is the inheritance
CharacterStats.prototype = Object.create(GameObject.prototype);
//Prototype Method is Created Here
CharacterStats.prototype.takeDamage = function() {
return `returns the string ${this.name} took damage.`
}
console.log(firstNamesAllCaps);
let firstNamesAllCaps = runners.map(function(currentValue){
return currentValue.first_name.toUpperCase();});
console.log(firstNamesAllCaps);
let runnersLargeSizeShirt = [];
runnersLargeSizeShirt = runners.filter(function(currentValue){
return currentValue.shirt_size === "L";
})
console.log(runnersLargeSizeShirt);
let ticketPriceTotal = 0;
ticketPriceTotal = runners.reduce(function(accumulator, currentValue){
return accumulator + currentValue.donation;
},0)
console.log(ticketPriceTotal);
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.
*/
class GameObject {
contructor(obj) {
this.createdAt = video.createdAt;
this.name = video.name;
this.dimensions = video.dimensions;
}
destroy() {
return `${this.name} was removed from the game.`;
}
}
class CharacterStats {
contructor(obj){
super(obj)
this.healthPiont = obj.healthPionts;
}
takeDamage() {
this.healthPiont = 1;
return `${this.name} took damage`;
}
}
class humaniod extends CharacterStats {
contructor(obj){
super();
this.team = obj.team;
this.weapon = obj.weapon;
this.language = obj.language;
}
greet() {
return `${name} offer greeting in ${language} @channel standy`;
}
debug(student,subject){
console.log(`${this.name} debugs `)
}
}