Basic JavaScript - Counting Cards

can someone please help me look into this cos i totally dont understand it anymore

let count = 0;

function cc(card) {
  // Only change code below this line
switch(card) {
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
  case 10:
  case "J":
  case "Q":
  case "k":
  case "A":

}var holdbet = "hold" 
if (count > 0) {
  holdbet = "bet"

  return + " " + "holdbet";
  // Only change code above this line

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; rv:109.0) Gecko/20100101 Firefox/111.0

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

Replace (count+1 & count -1) with ++ and – or count+=1 & count-=1

You have to assign the value back to count for the variable to be updated. It’s more obvious when you do count = count + 1 or count = count - 1, which can be shortened into count += 1 and count -= 1, respectively. And then you can go further and just use ++ or -- when you only want to increase or decrease the variable by 1.

But, when you just put count + 1 or count - 1 you aren’t affecting the actual value of count. This can be useful at certain times, but not for this particular function.

You may want to go back and go over all of the lessons again from start to finish. It seems like you might need a refresher of some of the previous concepts.

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