function cc(card) {
// Only change code below this line
if(card==2||card==3||card==4||card==5||card==6){
count+=1;
return count+"Bet";
}
else if(card==7||card==8||card==9){
return count +" Hold";
}
else if(card==10||card=='J'||card=='Q'||card=='K'||card=='A'){
count-=1;
return count+"Hold";
}
else{
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');
First of all, you need a space between the count and "Bet"
or "Hold"
. You are correctly changing count
, but not the "Bet"
or "Hold"
.
Currently you decide to return "Bet"
or "Hold"
based on the last input. But it should be determined by the value of count
. So you should remove the return
from the current if .. else
statement and create a new if ... else
statement checking if count
is larger than zero ("Bet"
), or equal or smaller than zero ("Hold"
).
And since the else if(card==7||card==8||card==9)
doesn’t change count
, you can remove it.
return count + (count > 0 ? ’ Bet’ : ’ Hold’);
I don’t understand the syntax use of ‘?’ and ‘:’. Where can I find this in the resource?