Hello, i’m feeling somewhat lost about the solution to this exercise - tests mention that function should return a string, but as we call same function multiple times … we get a number of strings, same with calling our hand as ‘card sequence’, as it’s only a ‘sequence’ in words.
Your code so far
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;
};
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');
Each function call returns a string. However, because this function depends on the global count variable, result for the same argument can change. Take a look:
console.log(cc(2)); // 1 bet
console.log(cc(2)); // 2 bet
console.log(cc(2)); // 3 bet
I know, i’m talking about how it returns a string for every card, rather than once per cards sequence.
I’m not exactly complaining, that’s just what ‘tests’ seem to imply.