ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

"parsing" a function return #124

Closed jkoul closed 9 years ago

jkoul commented 9 years ago

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]);

jkoul commented 9 years ago

Nevermind I got it figured out. Sorry for the trouble!