# 5. Hand Winner

In this section you will come up with the handWinner function. This function is going to look at the first card in each players hand. The player who has the higher 'card' will get both of the cards played. If there is a tie, the function will simply remove both cards from the players. This function needs to accept two parameters. The first being the user's card value, and the second being the pc's card value.

Think about how this happens with a computer. We have two cards, say user = 4 and pc = 3. This function gets those values, 4 and 3 and determines that the user has won the game. Since we cannot physically pick them up and move them, we need to copy both cards and append them to the end of the user's hand, and then go ahead and remove them from each player.
`function handWinner(userCard, pcCard){`
Hint

The logic is the same if the pc wins, only this time the cards get appended to the pc's hand, and then removed from each player.

Again, remember that if there is a tie, we simply remove both cards from the players

Once the switch has been made, the score should be updated, and we should go to the gameOver function to check and see if the game is over. Once we do those things the function is done.

Next
Back