Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.35 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Cannot get unique values in card array
  2. var usedCards= [];
  3.  
  4. function dealCards() {
  5.   for (i = 0; i < 3; i++)
  6.   {
  7.     var card = createUniqueCard();
  8.     usedCards.push(card.cardRepresentation);
  9.   }
  10. }
  11.  
  12. function createUniqueCard() {
  13.   do {
  14.     var newCard = new Card();
  15.   }
  16.   while (usedCards.indexOf(newCard.cardRepresentation) != -1);
  17.  
  18.   return newCard;
  19. }