problem statement is here: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards
the problem comes when i tried to get 0 Hold in the return by the Cards Sequence 7, 8, 9,but i can't. I know that there are better options for solving this problem, but i wanna do it this way, someone can help?
function cc(card) {
// Only change code below this line
if (card = ( 2 || 3 || 4 || 5 || 6 )) {
count += 1;
}
else if (card = ( 7 || 8 || 9 )) {
count += 0;
}
else if (card = ( 10 || "J" || "Q"|| "K" || "A" )) {
count -= 1;
}
if (count <= 0) {
return count + " Hold";
}
else if (count > 0) {
return count + " Bet";
}
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');```
Keeping the same gist of your function:
function cc(card) {
if ("23456".indexOf(card) >= 0) count++;
if ("10JQKA".indexOf(card) >= 0) count--;
return count + (count <= 0 ? " Hold" : " Bet");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.