Basic JavaScript - Counting Cards - How do you display the result with console.log?

1 Shouldn’t we be using a “for” for this?
2 How do you type the ‘console.log’ to see the result, because I put “console.log(cc(2, 3, 4, 5, 6));” and did not work.
Also I tried
console.log(cc(2), cc(3), cc(7), cc(‘K’), cc(‘A’));
And I got “1 Bet 2 Bet 2 Bet 1 Bet 0 Hold”

Your code so far

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 ++;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
    count --;

  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(2), cc(3), cc(7), cc('K'), cc('A'));

Your browser information:

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

Challenge Information:

Basic JavaScript - Counting Cards

use the arrey :


An array is a data structure that can hold multiple values or elements. In this case, the array contains a list of cards

Oh! You mean like this?

console.log(cc([2, 3, 4, 5, 6]));

I still think we should youse a “FOR” to properly solve this exercise, because values should be adding up.
On this case, the display says “0 Hold” which is not correct

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