Below is my answer for this exercise. It is exactly the same as listed for “Solution 1”, line-by-line. However, it fails every test. I’m not sure what’s occurring.
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');
I’ve checked it against Solution 1, and it’s identical from what I can tell. What am I missing here??
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
Please use the “preformatted text” tool in the editor (</>) to add backticks around text.
That sequence of calls just so happened to result in count being 0. You are successfully changing count. The issue is in the string that you return. Your output is not quite correct.