Issues with your test passing thing

Hi, there’s an issue I have founded on your test passing machine. There’s a case in Javascript basics and it’s passing the wrong code in it.

Please post your code and a link to the challenge

This is the link Basic JavaScript Counting Cards: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards and here’s my code :

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 +=1;
    break;
    case 7:
    case 8:
    case 9:
    break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
    count -=1;
    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');

console.log(cc("K"));

And what is wrong here?

console.log(cc(‘A’)); // Should return “0 Hold while it’s returning -1”
console.log(cc(3)); // Should return “-1 Hold while it’s returning 0 Hold”

The entire sequence of cards matters. You have to use the same sequence of cards to get the same result.

Ohh okay I got it, Thanks for explaining this, I thought my code is wrong and it is passing my code.

2 Likes

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