Tell us what’s happening:
Hi everyone !
I’m practicing coding on FreeCodeCamp for a few weeks now. I’m also using the app Grasshopper (There might be things that I learned there but not yet on Freecodecamp on my code).
I’m on the counting cards exercise right now, I haven’t looked at the answer since I find it intersting to code and I don’t want to get “spoiled” (sorry for my english, I’m actually french).
I understand that my code is wrong but I don’t really get why.
Anyone could tell me me the reason ?
Thank you !
**Your code so far**
var count = 0;
function cc(card) {
// Only change code below this line
var cardChangePlus = [2, 3, 4, 5, 6]
var cardChangeNul = [7, 8, 9]
var cardChangeMinus = [10, 'J', 'Q', 'K', 'A']
for(var numPlus of cardChangePlus) {
if(card === numPlus) {
return count++;
}
}
for(var numNul of cardChangeNul) {
if(count > 0 || card === numNul ) {
return count = count--;
} else if(count < 0 || card === numNul ) {
return count++;
}
}
for(var numMinus of cardChangeMinus){
if(card === numMinus) {
return count = count--;
}
}
return count;
// 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/88.0.4324.182 Safari/537.36.
Challenge: Counting Cards
Link to the challenge: