When I enter getValue(cardValues[1]) in the console, the return is 11.
But when I enter dealerScore (which equals that previous statement), the return is "A". What gives???
function getValue (num) {
var num;
if( num == '2' || num == '3' || num == '4' || num == '5' ||
num == '6' || num == '7' || num == '8' || num == '9' || num == '10') {
return value = parseInt(num);
} else if (num == "J" || num == "Q" || num == "K") {
return value = parseInt(10);
} else if (num == "A") {
return value = parseInt(11);
} else { return value = ""};
};
var cardValues = new Array();
for(i=0; i<cards.length;i++) {
cardValues[i] = cards[i].rank;
}
When I enter getValue(cardValues[1]) in the console, the return is 11. But when I enter dealerScore (which equals that previous statement), the return is "A". What gives???
function getValue (num) { var num; if( num == '2' || num == '3' || num == '4' || num == '5' || num == '6' || num == '7' || num == '8' || num == '9' || num == '10') { return value = parseInt(num); } else if (num == "J" || num == "Q" || num == "K") { return value = parseInt(10); } else if (num == "A") { return value = parseInt(11); } else { return value = ""}; };
var cardValues = new Array(); for(i=0; i<cards.length;i++) { cardValues[i] = cards[i].rank; }
dealerScore = getValue(cardValues[1]); playerScore = getValue(cardValues[2]) + getValue(cardValues[3]);