Any CodeCampers in NC?

Hello CodeCamper,

My name is Shak and I just completed my first HTML & CSS, and Bootstrap. I want to get better and practice more. Any campers know some good resource for a newbie to practice. Also any CodeCampers in NC?

Check out: A fast new way to find people in your city to code with

I’m in Southeastern NC, just north of Myrtle Beach, SC.

Cool, how long have you been apart of FreeCode? I’m moving back to Charlotte and wanted to see who is in the area and maybe start a meetup group.

I’ve been on here a bit over a month. I’m really enjoying working through the algorithms–I’m almost finished with the intermediate algorithm scripting. It looks like there is an FCC Charlotte group. Has a bunch of members but it doesn’t look too active. Unfortunately, there doesn’t appear to be one close to me. Maybe I’ll start a Myrtle Beach group.

Man, I’ve been going at this for the past 3 weeks and am on the Jquery? what do you want to do once you get your certificate? I think you should start one a meetup group once I move back to Charlotte.

I have a good job that I like, so I’m not really counting on earning these certificates getting me anything. I’m almost 40, so breaking into the web development field could be a pretty big hurdle. I really just love to learn new things and having this knowledge under my belt would only help me in my current job.

Hi Shak!

I’m in the Charlotte area. Let me know if you want to meet up some time, I would love to collaborate on some of this. I’m almost halfway through the JavaScript Challenges. When are you moving Charlotte?

Brian

Hey Brian,
I just started the JQuery section… we really could meet up soon and tackle this together. I will be in Charlotte tonight. Which part of Charlotte are you located?

Shako

I’m in the Weddington/Waxhaw area but can come toward Charlotte is too far out of the way for you. Right now, I’m stuck on some of the JavaScript challenges. It’s difficult to keep going when you are stuck and don’t quite know what search for. I won’t be available for the rest of this week, but will be available next week.

Are there any days that work better for you than others during the week?

Which of the challenges are you struggling with? I’m happy to help, if I can.

Hi Matt!

Right now, I’m stuck on the Counting Cards challenge in JavaScript. My first attempt has been to just use the if statements but that isn’t working. I’m sure that I need to use a switch statement, but I’m not sure what order I need to use it.

Any ideas?

Here’s what I have so far…

var count = 0;

function cc(card) {
// Only change code below this line
if (card === 0) {
return “Hold”;
}

if (card = 2, 3, 4, 5, 6) {
return +1;
}

if (card = 10, “J”, “Q”, “K”, “A”) {
return -1;
}

if (cc === -1, -2, -3, -4, -5) {
return “Hold”;
}

return “Change Me”;
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc(‘K’); cc(‘A’);

The single “=” is the assignment operator. It is used to assign a value to a variable. The “===” is used to compare values. Also, the comparisons you’re doing in the first 2 if statements won’t work. The first one should be

if(card >= 2 && card <= 6) {
  //do something
}

You wouldn’t want to return inside that if, you would want to increment (or decrement) your count variable.

Ok, I think I’m making progress. But I still need to figure out how to get the system to work and to calculate “Hold” or “Bet.” This is what I have…

if(card >= 2 && card <= 6) {
return +1;
}

else if (card >= 7 && card <=9){
return 0;
}

else if(card >= 10){
return -1;
}

else {
return -1;
}

You only need one return. The if and else if blocks shouldn’t be returning anything. They should be incrementing or decrementing a count variable.

Also, this

else if(card >= 10)

does not take into account the Jack, Queen, King, or Ace cards. You would want this to look something like

else if(card === 10 || card === "J" || //more conditions...

Thanks! I finally figured it out this morning. I had to use the switch function to get it done. It is a huge relief to have that completed now.

Awesome! This is what I had originally:

var count = 0;

function cc(card) {
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      if (count < 1) {
        return count + " Hold";
      }
      return count + " Bet"
    case 7:
    case 8:
    case 9:
      if (count < 1) {
        return count + " Hold";
      }
      return count + " Bet"
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      if (count < 1) {
        return count + " Hold";
      }
      return count + " Bet"
  } 
}

Later I went back and changed it to this:

var count = 0;

function cc(card) {
  if (card >= 2 && card <= 6) {
    count++;
  }
  if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
    count--;
  }
  if (count < 1) {
    return count + ' Hold';
  } else {
    return count + ' Bet';
  }
}

I guess in the end they both accomplish the same thing. I just liked the compactness of the if statements. You could even shorten this using regular expressions and the conditional/ternary operator, like so:

function cc(card) {
  var incrementRE = /[2-6]/;
  var decrementRE = /[10JQKA]/i;
  card.toString().search(incrementRE) > -1 ? count++ : card.toString().search(decrementRE) > -1 ? count-- : "";
  return count < 1 ? `${count} Hold` : `${count} Bet`
}

Your final solution is much more elegant. How did you come up with the increment/decrementRE? Where did you learn about that?

This was my final solution…


var count = 0;

function cc(card) {
  // Only change code below this line
switch(card) {
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
    count++;
   break; 
    
 
  case 10:
  case "J":
  case "Q":
  case "K":
  case "A":
    count--;
    
}   

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

    

  
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Hey I’m in Charlotte too! I just started Friday, so a bit behind you. Love this area!