Tell us what’s happening:
Your code so far
var count = 0;
function cc(card) {
// Only change code below this line
var val;
var finalcount=0;
for (var i = 0; i < arguments.length; i++) {
val= Number(arguments[i]);
if(val==2 || val==3 || val==4 || val==5 || val==6 )
{
count=1;
}
else if(val==10 || val=='J'|| val=='Q' || val=='K' || val=='A')
{
count= -1;
}
else
{
count=0;
}
if(count>0)
{
finalcount += count;
}
else
{
finalcount -= count;
}
}
if (finalcount > 0)
{
return finalcount +" " + "Bet";
}
else
{
return finalcount +" " + "Hold";
}
//return "Change Me";
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
//cc(2); cc(3); cc(7); cc('K'); cc('A');
//cc(2,3,4,5,6);
cc(10,'J','Q','K','A');
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/counting-cards