complete-javascript-course
complete-javascript-course copied to clipboard
Solution for challenge 1 of PIG game seem not correct
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