complete-javascript-course icon indicating copy to clipboard operation
complete-javascript-course copied to clipboard

Solution for challenge 1 of PIG game seem not correct

Open thangphamnd123 opened this issue 4 years ago • 0 comments

Here is challenge 1:

  • . A player looses his ENTIRE score when he rolls two 6 in a row. After that, it's the next player's turn. (Hint: Always save the previous dice roll in a separate variable)

My opinion: Since last dice of 2 player is different. If we use single variable (lastDice) to store value then it would lead to error in this specific case: player 1 roll the dice and got 6, he stop and hold. Then when player 2 dice, he also got 6 on his 1st tried, then in this case score of player 2 will be delete. ->Solution: use array lastDice = [0,0] to store the value.

Regards, Thang

thangphamnd123 avatar Apr 26 '21 17:04 thangphamnd123