Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda