function cc(card) {
// Only change code below this line
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;
}
if (count > 0) {
return count + " Bet";
} else {
return count + " Hold";
}
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
how can i console a whole sequence?
i have a doubt. here , break is given after case2-case6
so it will keep incrementing until case 6 .like this-
(0+1+1+1+1+1) ?
now in case of case 10-case" string".
will the count value start from 0 or from 5? my code
like console.log(cc(2), cc(3), cc(7), cc('K'), cc('A'));
no, there is only one single count++, so the number is increaseed only once
I don’t understand this question
this is empty and there is nothing to see
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
do you mean you want to see the value of count only?
you can add console.log(count) inside the function or you can add console.log(count) after each function call
var count=0;
function cc(card) {
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
}
return count;
}
1.i want to output a sequence in such a way that it return after being added at each cases?
for ex : for case2,case3,case4,case5,case6. it should return 5
(0+1+1+1+1+1)=5