Counting cards- confusion

Ok I am here again, trying to get my head around all this.
I had a look at the hints and followed advice but it doesnt run, is there something I am missing??
here is the code:

var count = 0;

function cc(card) {
  // Only change code below this line
  // check the value of each card with the switch statement
switch (card){
  case 2:
  case 3: 
  case 4:
  case 5:
  case 6:
  // the count variable increases by 1
  case 10:
  case "J":
  case "Q":
  case "K":
  case "A":
  // decrease the count by 1
  count --;
// check the value of the card and return appropriate response
if (count >0 ){
  return count + "bet";
  return count + "hold";
  // Only change code above this line

cc(2); cc(3); cc(7); cc('K'); cc('A');

what am I doing wrong? and can somebody explain the error to me pls, so I can better understand.

Look very carefully at what the expected return value should be and what you are returning.


You are missing spaces between your count and “bet” or “hold”.

I am still confused, lol!
Sorry I still dont quite understand the logic :worried:
i also see that it should return “5 bet” and “0 hold”
but doing that hasnt made a change either

I was wondering if:

if (count >=2 && <=6){
return count + "bet";
return count + "hold";

OK, thx
A very simple error:
spaces and Upper case letters
many thanks for your help :fu:

Glad I could help. Happy coding!

1 Like

I thought I was getting better, until I have these challenges and then I have to use the hints :worried:

Take it slow. Be patient with yourself. Never feel shy about coming here instead of or in addition to looking at hints. It’s more interactive and can help you get more out of the process.

Many thanks.
I might do that then, as its too easy to just look at answers :fu:

Ummm… Here’s hoping that was meant to be a thumbs-up. I really was trying to be supportive :flushed:

1 Like

you were being supportive :fu:
As I said , I will be trying harder and asking more questions on the forum now.
I need to get to understand the logic of the coding and how it works.
So I will try and solve the challenges myself and if I run into any trouble I will ask here :fu:

… You know you’re using the “fuck you” emoji?

what NOOO!!! shit
I thought it said thumbs up- OH sorry!!!
i was meant to use :+1:
im such an idiot!!

Hahahaha. No worries. Happy coding!

I have just been contacted for a Entry level Js Dev job, but I think I am no where near the level they are looking for.
The recruiter did say that the company do trian the candidates.
Its very hard to get into the industry, and Js is the one remaining language i need to get that foot in the door, so while I am looking for any work, I am also teaching myself, so I can get a better job too. :+1:

If you have a thick enough skin, it might be valuable to go through the process anyway just to experience what a tech interview is like. Honestly though, I wouldn’t be tough for that :slight_smile:

I would only get an interview if they thought that my skills were what they are looking for :crossed_fingers:

Good luck!

Here is my next challenge, wasnt right:

Read in the property values of testObj using dot notation. Set the variable hatValue equal to the object’s property hat and set the variable shirtValue equal to the object’s property shirt .

// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"

// Only change code below this line

var hatValue = testObj. "hat";      // Change this line
var shirtValue = testObj."shirt";    // Change this line

I am not sure what I am doing wrong here.

ok so I see that i have the wrong values, but the example wasnt make sense, so it should be:

var hatValue = testObj. "ballcap";      // Change this line
var shirtValue = testObj. "jersey";    // Change this line

but its not running.

the sample says:

var myObj = {
  prop1: "val1",
  prop2: "val2"
var prop1val = myObj.prop1; // val1
var prop2val = myObj.prop2; // val2

so again a bit confused as to the values that have to be used.

I have removed any spaces between the dot notation.