i’ve already tried a for loop but I’m new to javascript so it’s all still hard for me. I am grateful for any help. It should increase values. here´s my code:
JavaScript
x
39
39
1
prestige_btn.addEventListener('click', function(){
2
if(prestige_plus == 2){
3
taxi_pro_sec *= 3;
4
gartenArbeit_all_five_sec *= 3;
5
zeitungAustragen *= 3;
6
mehrLimoStände += 3;
7
}
8
if(prestige_plus == 3){
9
taxi_pro_sec *= 4;
10
gartenArbeit_all_five_sec *= 4;
11
zeitungAustragen *= 4;
12
mehrLimoStände += 4;
13
}
14
if(prestige_plus == 4){
15
taxi_pro_sec *= 5;
16
gartenArbeit_all_five_sec *= 5;
17
zeitungAustragen *= 5;
18
mehrLimoStände += 5;
19
}
20
if(prestige_plus == 5){
21
taxi_pro_sec *= 6;
22
gartenArbeit_all_five_sec *= 6;
23
zeitungAustragen *= 6;
24
mehrLimoStände += 6;
25
}
26
if(prestige_plus == 6){
27
taxi_pro_sec *= 7;
28
gartenArbeit_all_five_sec *= 7;
29
zeitungAustragen *= 7;
30
mehrLimoStände += 7;
31
}
32
if(prestige_plus == 7){
33
taxi_pro_sec *= 8;
34
gartenArbeit_all_five_sec *= 8;
35
zeitungAustragen *= 8;
36
mehrLimoStände += 8;
37
}
38
}});
39
and so forth.
Advertisement
Answer
JavaScript
1
9
1
for(const num of [2,3,4,5,6,7,8]){
2
if(prestige_plus===num){
3
taxi_pro_sec *= num;
4
gartenArbeit_all_five_sec *= num;
5
zeitungAustragen *= num;
6
mehrLimoStände += num;
7
}
8
}
9