Counting Cards different way to solve the problem

Tell us what’s happening:
HI all

I found the way to solve the counting Card Part using Switch and Case

However, online I have found people who used the below code I wrote

My question is if the sign "== " is the equal sign and the sign “||” mean ‘or’, how the computer interpret the below code.

I am a bit con fuse

Your code so far

var count = 0;

function cc(card) {
  // Only change code below this line

 if (card == 2 || card == 3 || card == 4 || card == 5 || card == 6){
   count ++;
  else if (card == 7 || card == 8 || card == 9){
    count += 0;
 return count +' '+(count > 0 ? "Bet" : "Hold")

  // Only change code above this line

// Add/remove calls to test your function.
// Note: Only the last will display
cc(7); cc(8); cc(9); cc(); cc();

console.log (cc());

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:

first use “===” instead “==” condition is if card equal 2 or 3 or 4 or 5 or 6 card will be increment else if card equal 7 or 8 or 9 count is 0 return count and if count great then 0 then u will get bet if not hold…

1 Like

When you are having difficulty understanding the code I find it best to write out the code in plain English. It will help you get a better grasp of what’s going on. This can be a little daunting with more complex loops, but you just have to break those down.

1 Like