Tell us what’s happening:
I have written solutions with bother if/else and switch statements however it would just count the strings and not the numbers in the array provided.
Typical output would look like this:
0
0
0
-1
-2
The first 3 0’s are for the numbers in the input array.
**Your code so far**
let count = 0;
function cc(card) {
// Only change code below this line
for (let i = 0; i < card.length; i++) {
console.log(typeof(card[i]));
if (card[i] >= 2 && card[i] <= 6) {
count++;
} else if (card[i] == 10 || card[i] == 'J' || card[i] == 'Q' || card[i] == 'K' || card[i] == 'A') {
count--;
}
}
console.log(count);
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/105.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Counting Cards
Link to the challenge: