JavaScript: returning NaN (Part 2)
<p>(note this is similar to but not the same as the question I asked moments ago - the solution to that question was to add the brackets when calling Math.Random)</p>

<p>At the bottom of the code below, I'm dealing out two hands of blackjack <code>myhand</code> and <code>yourhand</code> and then logging the hands to the console</p>

<pre><code>"I scored a "+myHand.score()+" and you scored a "+ yourHand.score());
</code></pre>

<p>However, the result I'm getting is</p>

<pre><code>I scored NaN and you scored a NaN
</code></pre>

<p>Originally, the getValue method in the Card constructor was passed a parameter called <code>card</code> but the instructions for building the Hand constructor said to call getValue without passing a parameter   </p>

<pre><code>this.card1.getValue();
</code></pre>

<p>so I changed the getValue method to take the <code>var number</code> (which is in the Card constructor)</p>

<p>anyways, to make a long story short, whatever i do, it's printing out</p>

<pre><code>I scored NaN and you scored a NaN
</code></pre>

<p>and I'm not sure exactly where I'm going wrong. </p>

<pre><code>// Make your card constructor again here, but make sure to use private
// variables!
function Card(num, suit){
    var number = num; 
    var suits = suit;
    this.getSuit = function(){
        return suits; 
    }; 
    this.getNumber = function(){
        return number; 
    };

    this.getValue = function(number){
        if (number &gt; 10){
            return 10; 
        }else if (number === 1){
            return 11; 
        }else{
            return number; 
        }

    };

}

function Hand(){
    this.card1 = deal(); 
    this.card2 = deal(); 

    this.score = function(){
    var score1 = this.card1.getValue();
    var score2 = this.card2.getValue();
    return score1 + score2;
    };

}

// Make a deal function here.  It should return a new card with a suit
// that is a random number from 1 to 4, and a number that is a random
// number between 1 and 13

var deal = function(){
    var suit = Math.floor(Math.random() * 4 + 1);
    var number = Math.floor(Math.random() * 13 + 1);
    return new Card(number, suit); 
}; 


// examples of the deal function in action

var myHand = new Hand();
var yourHand = new Hand();
console.log("I scored a "+myHand.score()+" and you scored a "+ yourHand.score());
</code></pre>
