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:
prestige_btn.addEventListener('click', function(){ if(prestige_plus == 2){ taxi_pro_sec *= 3; gartenArbeit_all_five_sec *= 3; zeitungAustragen *= 3; mehrLimoStände += 3; } if(prestige_plus == 3){ taxi_pro_sec *= 4; gartenArbeit_all_five_sec *= 4; zeitungAustragen *= 4; mehrLimoStände += 4; } if(prestige_plus == 4){ taxi_pro_sec *= 5; gartenArbeit_all_five_sec *= 5; zeitungAustragen *= 5; mehrLimoStände += 5; } if(prestige_plus == 5){ taxi_pro_sec *= 6; gartenArbeit_all_five_sec *= 6; zeitungAustragen *= 6; mehrLimoStände += 6; } if(prestige_plus == 6){ taxi_pro_sec *= 7; gartenArbeit_all_five_sec *= 7; zeitungAustragen *= 7; mehrLimoStände += 7; } if(prestige_plus == 7){ taxi_pro_sec *= 8; gartenArbeit_all_five_sec *= 8; zeitungAustragen *= 8; mehrLimoStände += 8; } }});
and so forth.
Advertisement
Answer
for(const num of [2,3,4,5,6,7,8]){ if(prestige_plus===num){ taxi_pro_sec *= num; gartenArbeit_all_five_sec *= num; zeitungAustragen *= num; mehrLimoStände += num; } }