Tell us what’s happening:
The following test cases are not working :
Cards Sequence 7, 8, 9 should return 0 Hold
Cards Sequence 3, 7, Q, 8, A should return -1 Hold
Cards Sequence 2, J, 9, 2, 7 should return 1 Bet
All these cases involve 7,8,9 for which the value of count does not change.
Your code so far
var count = 0;
function cc(card) {
// Only change code below this line
if(card<7 && card>1)
count++;
else if(card == 10||'J'||'Q'||'K'||'A')
count --;
if(count>0)
return count + " Bet";
else
return count + " Hold";
// 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');
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0.
Thank you for replying but I am unable to understand the mentioned mistake .
For case card=7, the statement else if(card == 10||‘J’||‘Q’||‘K’||‘A’) should return false and hence the value of count stays unchanged.
but it doesn’t evaluate to false, that’s the issue
that’s why I suggested you play a bit with that code snippet
let card = 7;
console.log(card == 10) // false
console.log(card == 10 || "J") // this is not false
you can’t convert the sentence “if card is equal to 10 or “J”” exactly like that in code
in code it must be “if card is equal to 10 or card is equal to “J””