Question on testing my javascript in the the lessons

For counting cards Javascript lesson, I was able to pass all of the tests using this code I wrote:

var count = 0;

function cc(card) {
switch(card) {
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
  count += 1;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;

var result = ("");

if (count >= 1){
result = (count + " " + "Bet")}
else if (count <= -1){
result = (count + " " + "Hold")}
if (count == 0){
result = (count + " " + "Hold")
return result }

However, when I put at the end this: console.log(cc(2, 3, 4, 5, 6));

it gives me 1 Bet, when it should give me 5 Bet.

Is there a way to use console.log properly so I can test the code I’ve written using my own inputs into the function?

The cc function only accepts one argument, so only the first value passed to it will be used by the function. You will need to call the function with each value separated by commas to see the result of each call to the function with a single console.log.

I put this at the end and it works! Thank you!!

@RandellDawson Is this what you meant?


That works too.

I meant:

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

You could also do something like:


That makes sense, thanks for explaining!