Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda