I have an object, Player, which has different properties for different rounds for example round_1, round_2, .. , round_7. I would like to give them values depending on the integer, round value.
What i thought would work would be with a function:
//voor = round in Estonian
function valiVoor(player, r){
if (r == 1){
return player.voor_1;
}
else if (r == 2){
return player.voor_2;
}
else if (r == 3){
return player.voor_3;
}
else if (r == 4){
return player.voor_4;
}
else if (r == 5){
return player.voor_5;
}
else if (r == 6){
return player.voor_6;
}
else if (r == 7){
return player.voor_7;
}
}
Although calling out function:
valiVoor(player_one,1) = "asd";
Will not change the property player_one.voor_1 = "asd". Should i work with arrays or is there any other option to resolve the issue?