The deck shuffling problem. Solved as with any other language. First you create an array containing the cards (or numbers representing them), and a variable telling how many cards are left. Then whenever you need to draw a card you pick a random integer number in the range of cards left, thus:
Math.floor(Math.random()*cardsleft) //return a number in the range 0 to cardsleft-1
Then you, pick the chosen card, and thereafter swich it with the last of the remaining card in the array.
A deck of four cards: [0,1,2,3], random pick from 0 to 3 return 0, thus the card in position 0 is put into the hand, and 0 is swiched back in order not to be picked again [3,1,2,0], random pick from 0 to 2 return 2, thus card 2 is put into the hand, it is already in the backmost position of the active part of the array, so it stays [3,1,2,0]. Random pick from 0 to 1 return 0, thus card 3 is put into the hand, and the 3 swich place with the 1 [1,3,2,0]. The last card left is then card 1 in position 0.
In order to make a new draw you don't even need to reset the array, only the counter.
Let me have a look at your game once you are done.