Tell us what’s happening:
In the challenge, just two of the “card sequence” doesn’t work, but just one does it.
Not working
Cards Sequence 10, J, Q, K, A should return the string -5 Hold
Cards Sequence 3, 2, A, 10, K should return the string -1 Hold
Working
Cards Sequence 3, 7, Q, 8, A should return the string -1 Hold
Please help me understand why it’s happening.
Cheers.
**Your code so far**
let count = 0;
function cc(card) {
// Only change code below this
if (card == 2){
count += 1;
}else if (card == 3){
count += 1;
}else if (card == 4){
count += 1;
}else if (card == 5){
count += 1;
}else if (card == 6){
count += 1;
}
if (card == 10){
count -= 1;
}else if (card == 'J'){
count -= 1;
}else if (card == 'Q'){
count -= 1;
}else if (card == 'k'){
count -= 1;
}else if (card == 'A'){
count -= 1;
}
if (count > 0){
return count + " Bet";
}else {
return count + " Hold";
}
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Counting Cards
Link to the challenge: