you have multiple functions. my recommendation is to test each method separate from the rest. you should verify that each piece works correctly.
i'd also suggest some sort of log feature so you know exactly what's in the deck at any point. something like so:
Code
void logDeck(){
log("numberOfCards: " + numCardsInDeck);
for (var i = 0; i < numCardsInDeck; i++){
log(i + ": " + cards[i]);
}
}
to remove the card from your deck, simply set it to null.
Thank you.