0

#1
``````var count = 0;

function cc(card) {
// Only change code below this line
if(card > 1 || card < 7) {
return count++;
} else if (card <= 9) {
return card += count;
} else if (card <= "Z" && card <=10) {
return card += count--;
}

// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
``````

#2

I’m not sure what you’re asking. If you would, link to the exercise and explain more what you need help with, please.

#3

#4

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 easier to read.

Note: Backticks are not single quotes.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

Your logic is not right yet. You should probably try an write out your algorithm in plain language first, before trying to write JavaScript code.

Your current function code first checks if card is greater than 1 OR card is less than 7 you return the incremented value of count. There are two problems with this first if statement:

1. Because you are using || (Or), if either of the conditions evaluates to true, the entire if statement evaluates to true. What this means, is card values of 2, 3, 4, 5, 6, 7, 8, 9, 10 will all cause card > 1 to evaluate to true, which is not what you want.

2. You are basing what gets returned by the function on the card values themselves. This is not the correct logic. You need to based the returned value of the function on the current value of count.

Problem #2 above is part of a greater issue with your code which is you need to separate this problem into two sections. The first section should calculate the value of count based on the card values. The second section should return a string which includes the count value (after any calculations are made to it in the previous section) and either " Bet" if count is greater than zero or " Hold" if count is not greater than zero.

#5

All right i will get on that please… thanks and God bless you.