Can not figure out what I’m doing wrong.
To explain briefly, we are supposed to write a program that keeps track of the ‘count’ in blackjack. 2-6 raises the count by 1, 7-9 keeps the count the same, and 10-Ace lowers the count by 1. The program should return the count, along with either “Bet” (if the count is positive) or “Hold” (if the count is negative).
‘answer’ is what I named the variable for ‘Bet’ or ‘Hold’.
let count = 0;
function cc(card) {
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = count + 1;
break;
case 7:
case 8:
case 9:
count = count + 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count = count - 1;
break;
}
var answer = '';
if (count < 0) {
answer = 'Bet';
}
else if (count >= 0) {
answer = 'Hold';
}
return (count + ' ' + answer);
return "Change Me";
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
Challenge: Basic JavaScript - Counting Cards
Link to the challenge:
