Tell us what’s happening:
Hi, my solution keep failing, I reduced my switch statment to yours.
The only difference what remains is the ternary operator in the adviseMe().
As soon as my function is replaced with your if-elseif then it works.
I can’t see what is wrong, what I keep looking over.
Any idea please?
Your code so far
var count = 0;
function cc(card) {
// Only change code below this line
function adviseMe(value) {
var answer = "";
value > 0 ? answer += value + " Bet" : answer += value + " Hold";
return answer;
}
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;
}
console.log(adviseMe(count));
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0.
Thanks, I think it returns the value to the cc(), so just one level above,
therfore it can not reach the surface. Now it works! Big Thanks again!
The final version is:
var count = 0;
function cc(card) {
// Only change code below this line
function adviseMe() {
var answer = count + (count > 0 ? " Bet" : " Hold");
return answer;
}
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;
}
return adviseMe();
}