Tell us what’s happening:
I dont really understand why my code is not working. I do the same thing in c# and it works. Waht is the difference here.
Your code so far
let count = 0;
function cc(card) {
// Only change code below this line
if(card === "J" || card === "Q" || card === "K" || card === "A" || card === 10){
count--;
}
else if(card === 7 || card === 8 || card === 9)
{
//nothing happens
}
else if(card === 2 || card === 3 || card === 4 || card === 5 || card === 6)
{
count++;
}
else if(count > 0)
{
return count + " Bet";
}
else if(count <= 0)
{
return count + " Hold";
}
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
var a = cc(2);
console.log(a);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Counting Cards
Link to the challenge: