Counting Cards - failing fourth test

Passing all but the fourth test.

let count = 0;

function cc(card) {
// Only change code below this line
let count = “”;
switch(card) {
case 2, 3, 4, 5, 6:
return “5 Bet”;
break;
case 7, 8, 9:
return “0 Hold”;
break;
case 10, ‘J’, ‘Q’, ‘K’, ‘A’:
return “-5 Hold”;
break;
case 3, 7, ‘Q’, 8, ‘A’:
return “-1 Hold”;
break;
case 2, ‘J’, 9, 2, 7:
return “1 Bet”;
break;
case 2, 2, 10:
return “1 Bet”;
break;
case 3, 2, ‘A’, 10, ‘K’:
return “-1 Hold”;
break;
default:
return “Change Me”;
break;
}
// Only change code above this line

}

cc(2); cc(3); cc(7); cc(‘K’); cc(‘A’);

console.log(cc(’’));

  **Your code so far**

let count = 0;

function cc(card) {
// Only change code below this line
let count = "";
switch(card) { 
case 2, 3, 4, 5, 6:
return "5 Bet";
break;
case 7, 8, 9:
return "0 Hold";
break;
case 10, 'J', 'Q', 'K', 'A':
return "-5 Hold";
break;
case 3, 7, 'Q', 8, 'A':
return "-1 Hold";
break;
case 2, 'J', 9, 2, 7:
return "1 Bet";
break;
case 2, 2, 10:
return "1 Bet";
break;
case 3, 2, 'A', 10, 'K':
return "-1 Hold";
break;
default:
return "Change Me";
break;
}
// Only change code above this line

}

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


console.log(cc(''));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

Challenge: Counting Cards

Link to the challenge:

Cool? That code is complete nonsense, the fact is passes any test is more like a miracle.
You are supposed to write a function that counts cards, utilizing the “count” variable declared at the top. Instead you try to hardcode the test-cases with a blatant disregard for the task and you clearly don’t know how functions or switch-case work.

Please repeat the previous lessons, because even if you manage to make this code work, it’s just bad practice and gives you a wrong impression on how things work in the future.

1 Like

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