I am receiving the proper outputs but I am not passing the tests.
Your code so far
var count = "0";
function cc(card) {
// Only change code below this line
switch (card)
{
case 2:
count++;
break;
case 3:
count++;
break;
case 4:
count++;
break;
case 5:
count++;
break;
case 6:
count++;
break;
case 7:
count+=0;
break;
case 8:
count+=0;
break;
case 9:
count+=0;
break;
case 10:
count--;
break;
case 'J':
count--;
break;
case 'Q':
count--;
break;
case 'K':
count--;
break;
case 'A':
count--;
break;
}
if (count > 0){
return console.log(count + " Bet");}
else (count <= 0)
return console.log(count + " Hold");
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36.
Ok I found out what I was doing incorrectly… I got rid of the console.log() bit and that passed the test. I was wondering if someone can tell if the original code is still correct?
var count = "0";
function cc(card) {
// Only change code below this line
switch (card)
{
case 2:
count++;
break;
case 3:
count++;
break;
case 4:
count++;
break;
case 5:
count++;
break;
case 6:
count++;
break;
case 10:
count--;
break;
case 'J':
count--;
break;
case 'Q':
count--;
break;
case 'K':
count--;
break;
case 'A':
count--;
break;
}
if (count > 0){
return count + " bet";}
else (count <= 0)
return count + " hold";
}
Your original code is not correct. Console.log only prints out the values to a log so you can see them. Returning a console.log of a value does not actually return the value for you.
Thanks for the tip. I posed the question because in the test output I could see the logic of the code working. So I was confused as to why I was getting it wrong.
I just wanted to mention it because the undefined returned from console.log() sometimes confuses people.
But I can see how the output might be confusing. If you want to log the return value from a function you can wrap the call to the function inside a log.
output completely lowercase instead of capitalized as required
why have you changed the starting value of count? I mean, it’s JavaScript so it’s not like it doesn’t work, but it was a number originally, not a string
it works anyway, because it’s JavaScript and it’s losely typed, but you are adding to a string, that’s confusing. You shouldn’t change a number that needs to be added or substracted to a string