for some reason when i use more than 2 console log’s on the function it return undefined. This seems to only be happening after the actually +1 an -1 of the count vairable
Your code so far
let count = 0;
function cardCounter (card) {
if (2 <= card && card <= 6){
count++;
}
else if(10 == card || card == "J" || card == "Q" || card == "K" || card == "A"){
count--;
};
// AFTER THIS POINT IT FAILES
if (count <= 1){
return `${count} Bet`
}
else if (count <= 0){
return `${count} Hold`
}
}
console.log(cardCounter(1))
console.log(cardCounter(2))
console.log(cardCounter(5))
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Challenge Information:
Build a Card Counting Assistant - Build a Card Counting Assistant
If the function is expected to return a value, it’s common to assign a default value to return, even if it’s an empty array or string, etc. But not all functions are expected to return a value i.e. if they are just performing a task