Making Yahtzee with JS. Simple question hopefully!

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?

Your code does exactly what you described: diceNr.1 has hold set to true and its value is never changed (always 0);

Sorry I don’t think I explained myself very well.

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.

Your code is currently missing this part.
Create a function that sets the dice to hold and call it between dice rolls;