Counting cards exercise description confusion

Hi fellow campers !
As exercises are getting more difficult, so do the texts, describing the tasks.
It’s a second time I have a problem understanding what exactly is wanted from me.
Please help me correctly interpret the following text in Italian style:

You will write a card counting function. It will receive a card parameter, which can be a number or a string, and increment or decrement the global count variable according to the card’s value (see table). The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative. The current count and the player’s decision ( Bet or Hold ) should be separated by a single space.

What is meant by “the function will then return a string with the current count” ?
Does it mean I have to use return statement ? if so, how can I return ‘Bet’ or ‘Hold’ afterwards, if executing RETURN statement is the last thing performed by JS. it stops after it.?
Do they really want me to return a string with the current count ?
Do I have to create an array with the all possible numbers as strings ?

Hope to learn understanding correctly the tasks like this.
Thanks in advance!
Happy Easter everyone !

you need to create a string that contains both the current count and the word “Bet” or “Hold”, example 3 Bet, -1 Hold

there is a count variable, its value has to be in the output of the function


your output has to include both the count and Bet/Hold


no, the number is already in the count variable

Thanks for such a a quick reply. Maybe I haven’t explained my questions well enough. sorry.
count variable holds numbers, not strings, if I use RETURN (return count), I won’t be able to return anything else within this Switch Statement. Does it mean that it’s better to create another statement, lets say IF, which will return HOLD/BET ?

If I understand correctly, I have to create a statement, which will change the count and then check if the count variable is less or equal to zero.
One more thing: I think that before each entry of a new card value the count will be equal to zero, as there is no loop. That way we can’t count correctly multiple cards. Is it right ?
my code :slight_smile:

var count = 0;

function cc(card) {
  // Only change code below this line
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count += 1;
    case 7:
    case 8:
    case 9:
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count -= 1;

  if(count <= 0){

no, count is a global variable, each time the function is called its value may be changed

there are five function calls at the bottom
try adding `console.log(count) between each of them

changing count and creating function output needs to be separated, yes

I needed to use return instead of console.log and I didn’t know I can actually concatenate with Return !
So all done.
Thank you for a support !

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