Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
How can i solve the Counting Cards exercice of freecodecamp with my code?

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');```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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");
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!