Javascript Exercise: Counting Cards with .include() method

Tried to use the .include() method to determine whether to increment/decrement the count but my code failed all the tests.

var count = 0;

function cc(card) {
// Only change code below this line
var bet = "hold";
var addOne = [2,3,4,5,6];
var minusOne = [10, "J", "Q", "K", "A"];
if (addOne.includes(card))
  count++;
else if (minusOne.includes(card))
  count--;

if (count > 0 )
  {
    bet = "bet";
  }

return (count + " " + bet);
// Only change code above this line
}

console.log(cc(3));
console.log(cc(2));
console.log(cc("A"));
console.log(cc(10));
console.log(cc("K"));

cc(2); cc(3); cc(7); cc('K'); cc('A');
  **Your browser information:**

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

Challenge: Counting Cards

Link to the challenge:

check the requirements for the output. Capitalization matters, JavaScript is case sensitive


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thank you very much!

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