My code seems correct according to the solution but when I test it, I don’t get the same output as that recommended in the exercise
Hello team. This is my first post, so apologies in advance for any faux pas I commit in asking my question.
This is my code and I had to get help from the hints in the solution. I understand why this should work and all that is well and good but when I test it using the console.log function, I don’t get the same output as that recommended in the exercise.
For example, according to the problem, "Cards Sequence 10, J, Q, K, A should return the string -5 Hold
" But my code returns -1 Hold
. I have tested all the sequences suggested and none of them matches the recommended output.
Any idea why that might be?
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;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
}
var betorhold = "Hold";
if (count > 0) {
betorhold = "Bet";
}
return count + " " + betorhold;
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
console.log(cc (10,'J','Q','K','A'))
console.log(cc (7, 8, 9))
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36
Challenge: Counting Cards
Link to the challenge: