Why this doesn't work? counting cards JS basic course

let count = 0;

function cc(card) {
// Only change code below this line
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;

case 10:
case ‘J’:
case ‘Q’:
case ‘K’:
case ‘A’:
count --;
break;
}

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’);

I don’t get it at all. Not sure what’s wrong here.
the indentation here seems wrong but I have no idea how to fix it. However, it is correctly indented, so if you want to check I could paste elsewhere (I have no idea how it’s done here)

Unfortunately I can’t help you… I’m too new myself. I’m having difficulty with the same problem, but in a different way. I thought I’d try piggybacking on your thread instead of creating a new one.

My problem is when I try to watch the Video help, it says I have to sign in, but I am already signed in. I tried doing it through GitHub, and it says GitHub refuses to answer. Is there a way to get the videos working again?

Please post a link to the challenge you are working on.

Rather than testing with:

cc(2); cc(3); cc(7); cc('K'); cc('A');

Why not see what you’re actually returning?


console.log(cc(2));
console.log(cc(3));
console.log(cc(7));
console.log(cc('K'));
console.log(cc('A'));

hi! it’s here: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards

I figured why, it’s pretty stupid.
FCC asks for this:

Your function should return a value for count and the text (

Bet

or

Hold

) with one space character between them.

my return was

return count + “Bet”

instead of

return count + " Bet"

soooooo it may be pretty stupid on my part

oh I wish I could help. I think maybe some scrimba users could help maybe? but quite the weird behavior here. hope you solve it soon!

Stupid mistakes are a part of coding. You just get better at finding them.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.