Does anyone know how to solve step 4? ‘after the cards 2, 3,4,5, then calling cardCounter(6) should return the string 5 bet ‘ question.
Tell us what’s happening:
I cant figure out step 4 with the build a cardCounter assistant task. Does anyone know how to make the console return 5 Bet?
Your code so far
let count = 0;
let decision = count > 0 ? "Bet" : "Hold";
function cardCounter(card) {
switch(card) {
case 2:
count +=1;
break;
case 3:
count +=1;
break;
case 4:
count +=1;
break;
case 5:
count +=1;
break;
case 6:
count +=1;
break;
case 7:
count +=0;
break;
case 8:
count +=0;
break;
case 9:
count +=0;
break;
case 10:
count -=1;
break;
case "J":
count -=1;
break;
case "Q":
count -=1;
break;
case "K":
count -=1;
break;
case "A":
count -=1;
break;
} return count + " " + decision;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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
Welcome to the forum @Codecamp33
I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.
Happy coding
Consider the scope of the decision variable.
Happy coding
you put decision here outside the function, do you think its value is ever going to change?
I’ve revised some stuff but am still completely stuck with create a number counting assistant. what’s wrong with the code so far. The console says everything’s fine and returns 5 bet for step 4 , but the only step that is accepted by the program is step 1. says everything else is wrong. Have tried every variation on the code that i could come across and nothing satisfies both the program and returns five bet for step 4.
Tell us what’s happening:
redid the problem from step 1 through 4, as far as i know. can make the console return 5 bet for step 4, and no other errors, supposedly. but cannot satisfy the steps in the program and get it to return 5 bet. have tried every variation I could come across and nothing works for both. what’s wrong so far? This is for the build a card counting assistant.
Your code so far
let count = 0;
function cardCounter(card) {
return count + (Bet, Hold);
}switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
}
let decision = count > 0? "Bet":"Hold";
return count + "" + decision;
}
cardCounter(2);
cardCounter(3);
cardCounter(4);
cardCounter(5);
console.log(cardCounter(6));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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
Hi @Codecamp33
I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates.
Thanks.
There is a message in the console.
SyntaxError: unknown: ‘return’ outside of function. (21:0)
19 | }
20 | let decision = count > 0? “Bet”:“Hold”;21 | return count + “” + decision;
| ^
22 | }
23 | cardCounter(2);
24 | cardCounter(3);
Happy coding
after you fix the syntax error, test what your function is returning and compare with the requested result