Basic JavaScript - Counting Cards

Why doesnt my code work ? It returns the correct value however it says the task is not completed? Any issues with my code? What’s wrong? Works pretty well to me

Your code so far

let sum = 0;
function cc(card) {
  
  // Only change code below this line
if (card >=2 && card <=6) {
  sum +=1;
}
else if (card >6 && card <=9) {
 
}
else {
  sum -=1;
}
var n = ''
  if (sum > 0) {
    n = ' Bet'
  return sum + nig}
  else if (sum <= 0) {
    n = ' Hold'
  return sum + n};
  
  }



cc(1); cc(1); cc(1); cc(1); cc(5);
console.log(cc(10))

Challenge: Basic JavaScript - Counting Cards

Link to the challenge:

You should be using the variable count in this exercise, not sum.
Also, you have a typo in this line:

return sum + nig

Fix those things and your code should pass the challenge.

thanks, did not see the count variable at the start so i created my own then deleted the ‘count’ var and replaced it with my own.
works now tho

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.