Counting Cards code not working with loop

Counting Cards code not working with loop
0.0 0

#1

Tell us what’s happening:
Please review my code and let me know what is going wrong which is why code is not working ?

Your code so far


var count = 0;

function cc(card) {
  // Only change code below this line
var arrayofalphabets = [2, 3, 4, 5, 6];
var arrayofnumbers =[	10, 'J', 'Q', 'K', 'A'];

if(arrayofalphabets.indexOf(card) > -1){
    count ++;
}  
else if(arrayofnumbers.indexOf(card) > -1) {
  count --;
}  
  return count > 0 ? count + 'Bet' : count + 'Hold';
  // 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');

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/counting-cards


#2

Are you missing a space between the count value and the string?


#3

haha ! true…such a silly mistake cost me a whole day !thanks there


#4

The devil’s in the details.