Build a Card Counting Assistant - Build a Card Counting Assistant

Tell us what’s happening:

Build a Card Counting Assistant
All tests passes (Completed the challenge) but not understanding the test cases .
My test case for this test
Passed:9. After the cards 2, 2, then calling cardCounter(10) should return the string 1 Bet. runs -1 Hold. Or maybe I dont understand the process. I just read the instructions, wrote the code and passed the challenge. Can anyone help me understand the test by saying after the cards, 2,2?

Your code so far

let count = 0
const cardCounter = card => {
  if (card >= 2 && card <= 6) {
    count++;
  } else if (card >=7 && card <=9) {
    count;
  } else if (card === 10 || card === "J" || card === "Q" || card === "K" || card === "A") {
   count--; 
  }

  if (count > 0) {
    return `${count} Bet`
  } else if (count <= 0) {
    return `${count} Hold`
  }
}
console.log(cardCounter(2));
console.log(cardCounter(3));
console.log(cardCounter(4));
console.log(cardCounter(5));
console.log(cardCounter(6));
console.log(cardCounter(7));
console.log(cardCounter(8));
console.log(cardCounter(9));
console.log(cardCounter(10));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Card Counting Assistant - Build a Card Counting Assistant

You seem to be on the right track with your test logs. But since count is global, you would want to reset to 0 before each test. For example, Test #4 says, “After the cards 2, 3, 4, 5, then calling cardCounter(6) should return the string 5 Bet.” So, your test for that would look like this:

// Test #4
count = 0;
cardCounter(2);
cardCounter(3);
cardCounter(4);
cardCounter(5);
console.log(cardCounter(6)); // 5 Bet

Another way to approach this would be to create a helper function that processes an array of all the previous card values to simulate counting all of the previous cards a Blackjack dealer has dealt to players.