Hello. I’ve just started with the logic for making the dice game Yahtzee in JS.
I have a function called diceRoll(). It’s very simple. It generates a random number between 1 and 6 and assigns it to dice.currentValue in each object. But if dice.hold is set to true, a new number won’t be assigned, and the dice.currentValue will stay the same until dice.hold is set to false.
But it doesn’t do that.
Here is the repl.it. Any ideas where I’m going wrong?
All dices start with hold set to false, so with every roll they are assigned a random number. Lets say after a few rolls dice 2’s value is 5. Then I set dice 2 hold value to true. I want dice 2’s value to stay at 5 while the other four dice values keep changing. Does that make sense.