Hello, so as you can see in the code included I got the solution to this problem by taking care of multiple inputs and using the case++; method at the end of case 6.
But what I am confused at is I initially tried this:
case 2:
count + 1;
case 3:
count + 1;
case 4:
count + 1;
case 5:
count + 1;
case 6:
count + 1;
break;
and more annoyingly this
case 2:
case 3:
case 4:
case 5:
case 6:
count + 1;
break;
and neither worked, until i merely just had count++; at the end of case 6. Can somebody please explain to me the difference here ? Many thanks and much appreciated.
As you can see below is my answer that worked.
let 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;
}
if (count > 0){
return count + " Bet";
}
else{
return count + " Hold";
}
// 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203
Challenge: Basic JavaScript - Counting Cards
Link to the challenge: