I'm new to programming and javascript and am having trouble changing a value in a one of my arrays throught its index. The rest of the code works fine but I can't seem to access my faces[] through its index, while in another array it works fine.
f1 = 0;
f2 = 0;
f3 = 0;
f4 = 0;
f5 = 0;
f6 = 0;
faces = [f1, f2, f3, f4, f5, f6];
//loop through a single throw with 5 dies
for(var i = 0; i < dice.length; i++){
var die = Math.floor(Math.random() * 6) + 1;
//if hold is true skip the corresponding iteration
if(hold1 == true && i===0){
alert("holding: " + held[0]);//shows the value of the die that's being held
for(var i = 0; i < 6; i++){
faces[i] = 5;//doesn't add anything
faces[2] = 5; //nor does this
faces[1]++; //or this
f1 = 3; //this works however
}
alert("faces are: " + f1 + ", " + f2 + ", " + f3 + ", " + f4 + ", " + f5 + ", " + f6);
continue;
}
//rest of code
The alert is to check if the values change and it returns 3, 0, 0, 0, 0, 0 since only assigning it to the variables in the index directly seems to work.