I feel like I’m hopeless at javascript. As soon as I’m ‘sort-of’ understanding a topic we move past it in the curriculum. I can’t pass the Card Counting exercise. Here’s my code:
var count = 0;
function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
return count +=1;
break;
case 7:
case 8:
case 9:
return count +=0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
return count -=1;
break;
}
if (count > 0){
return count + "Bet";
} else {
return count + "Hold";
}
return "7";
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Here’s the link to the exercise:
Why do I fail!?