title: Why is this if statement always true when it shouldn't be?
body: <p>I'm making a game where the goal is to get pairs of 4 using a normal card deck. When I prompt for which card value the player wants to ask another player, the <code>else if (playerArray[turn].cards.indexOf(card) == -1)</code> ALWAYS evaluates to true, even when the card variable contains a value of the cards array. This makes no sense to me at all and I'm stuck on how to fix this. Any suggestions is greatly appreciated.</p>
  
  <pre><code>var playerArray = [];       //Holds the player objects
  var turn = 0;               //Keeps track of whose turn it is
  var wrongCard = true;
  var card = askCard(player); //Prompt to get a card value
  
  function askCard(player) {
  
      var whichCard = prompt('The deck has: ' + deck.length + ' cards left in it.\n'
      + 'Your current cards are: ' + playerArray[turn].cards.join(' - ') + '\n'
      + player + ', all your:');
  
      return whichCard;
  }
  
      while (wrongCard) { //Run as long as the card input is wrong
  
          if (card &lt; 1 || card &gt; 13) { //If card value is not between 1-13
              card = askCard(player);
          }
  
          //If the asked card doesn't exist in the current player's cards array
          else if (playerArray[turn].cards.indexOf(card) == -1) { //ALWAYS TRUE, WHY?
              card = prompt('The deck has: ' + deck.length + ' cards left in it.\n' +
                            'Your current cards are: ' + playerArray[turn].cards.join(' - ') 
                            + '\n' + player + ', all your:');
          }
  
          else {
              wrongCard = false; //Jump out of loop
          }
      }
  </code></pre>