Hello I want to know why my code won’t work. I feel like the if and else statement are what should work for the last part
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 += 1;
break;
case 7:
case 8:
case 9:
count += 0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count -= 1;
}
if(count <= 0){
return count + "Hold";
} else {
return 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(7); cc('K'); cc('A');```
Hi, I am a JS newbie. My understanding of the scripting language is advancing. So my question here is - since the count variable was declared as global scope, how is it that when the function cc was initiated, that the count variable can be used with the local scope of that function?
I don’t know what you actually mean, you can just type console.log(whatever) and it will be logged in the console. If you still have question, you can paste your code here and let us see what is going wrong.