Counting Cards problem with different solution

Counting Cards problem with different solution
0

#1

I am not understand with between these code below what is the difference between these?
First system is working well that is commented and the another system that is not commented what is the problem?
thank you for your help.

var count = 0;

function cc(card) {
  // Only change code below this line

// First system

//   switch (card) {
//       case 2:
//       case 3:
//       case 4:
//       case 5:
//       case 6:
//       count++;
//       break;
//       case 10:
//       case "J":
//       case "K":
//       case "Q":
//       case "A":
//       count--;
//       break;
//       case 7:
//       case 8:
//       case 9:
//       count = count;
//       break;
//     }
  
//   if (count > 0 && count < 7) {
//     return count + " Bet";
//   } else if (count == 0) {
//     return count + " Hold";
//   } else {
//     return count + " Hold";
//   }
  
// Second system

  if (card >= 2 && card <= 6) {
    count++;
    if (count > 0 && count < 7) {
      return count + " Bet";
     }
  } else if (card == 10 || card == "A" || card == "K" || card == "Q" || card == "J") {
    count--;
    if (count < 0) {
      return count + " Hold";
    }
  } else {
    switch (card) {
      case 7:
      case 8:
      case 9:
        count = count;
        return count + " Hold";
    }
  }
  
  return "Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

#2

In your current logic, if the card is 10,“J”, “Q”, K", “A” and the count is great or equal you are returning “Change Me”, because nothing else prompts a different return statement.

In general, anytime the count <= 0, there will be a " Hold" after the count. If the count is > 0, then there will be a " Bet" after the count.

NOTE: You are currently using if (count < 0) for your Hold and it should be <=


#3

But what is difference with this? Please.

if (card >= 2 && card <= 6) {
    count++;
    if (count >= 1) {
      return count + " Bet";
     }
  } else if (card == 10 || card == "A" || card == "K" || card == "Q" || card == "J") {
    count--;
    if (count <= 0) {
      return count + " Hold";
    }
  } else {
    switch (card) {
      case 7:
      case 8:
      case 9:
        count = count;
        if (count <= 0) {
           return count + " Hold";
        } else {
           return count + " Bet";
        }
    }
  }
  
  return "Change Me";