-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathstrategy.js
80 lines (57 loc) · 1.18 KB
/
strategy.js
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
/* Ejemplo base */
class alumnHard{
constructor(){
this.iq = 90;
this.studyPower = 100;
}
studyStat(){
return this.iq+this.studyPower;
}
}
class alumnLazy{
constructor(){
this.iq = 20;
this.studyPower = 50;
this.funLevelr = 90;
}
studyStat(){
return (this.iq+this.studyPower)-this.funLevel;
}
}
class test{
constructor(){
this.alumn = null;
}
setAlumn(alumn){
this.alumn = alumn;
}
make(){
this.alumn.study();
}
}
let mathTest = new test();
mathTest.setAlumn(new alumnLazy());
mathTest.make();
mathTest.setAlumn(new alumnHard());
mathTest.make();
/* EJemplo con busquedas */
class person{
constructor(name,sex,age){
this.name = name;
this.sex = sex;
this.age = age;
}
}
let nameFilter = (list,val)=>{
list.filter((item)=>(item.name==val));
}
let sexFilter = (list,val)=>{
list.filter((item)=>(item.sex==val));
}
let ageFilter = (list,val)=>{
list.filter((item)=>(item.age==val));
}
let peoples = [new person('Damian','M',30),new person('Paul','M',40),new person('Michael','M',20),new person('Jennifer','F',50)];
nameFinder(peoples,'Damian');
sexFilter(peoples,'F');
ageFilter(peoples,30);