Output seems correct for every scenario. I need to improve my testing skills ASAP. I cannot determine why this is failing. It is really similar to what the solutions recommend.
I have tried using the JSON.Stringify command to make the whole output a string vs just the ‘Hold’ and ‘Bet’ portions. I have done the return code section as a function and also by creating and changing a variable. I like the function method more and it works so that’s what my code uses.
I strongly suspect I have something very obvious in the output format that’s causing the fail. ‘A’ and ‘K’ inputs are strings, right? I cannot figure out how to get my code to accept just A. It has to be ‘A’. Is that the issue?
Any chance my love of console.log() is messing me up here?
**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;
}
}
function action(count) {
if (count >0) {
console.log(count+ ' Bet');
return (count+ ' Bet');
} else {
console.log(count+ ' Hold');
return (count+ ' Hold');
}
}
// Only change code above this line
cc(3); cc(2); cc('A'); cc(10); cc('K');
action(count);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
That chunk of code is generating an output by combining the running count info with the recommended Hold/Bet action. I know it is super clunky but I think it works. I’ve been missing with the inputs just to see if I can make my code throw the wrong answer. What kills me is that I can feed it inputs that the test provides as examples and I get the output desired - yet it fails. Feels like I am doing some creative reading and my brain is skipping right past an issue somewhere.
I think that’s where I’m confused. Cheating and using the video solution - it uses the CC function to generate the running count. The output from the return statement then uses that count, but also another variable based on the count. Variable is ‘holdBet’.
You don’t need to create additional variables. You just need to put your two functions together instead of isolating half of the problem into a function that is never used by the tests.