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

273
Vistas
Why is my JavaScript code not accepted as the right answer?

I am trying to do this Javascript exercise: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards

I am wondering why the solution below is not an accepted answer:

let count = 0;

function cc(card) {
  // Only change code below this line
  const low = [2, 3, 4, 5, 6];
  const high = [10, 'J', 'Q', 'K', 'A'];

  if (low.includes(card)) {
    count += 1;
  }

  else if (high.includes(card)) {
    count -= 1;
  }

  let decision;

  if (count > 0) {decision = "Bet"}
  else {decision = "Hold"}

  return count + decision;
  // Only change code above this line
}

cc(2); cc(3); cc(7); cc('K'); cc('A'); 

When I am comparing it to accepted answers I don't see what they are doing differently. One thing that is not clear to me in the assignment is that should return be called every time or only after the last function call (cc('A');).

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Add a space between count and decision

  return count + " " + decision;
about 4 years ago · Juan Pablo Isaza Denunciar

0

You are giving an answer in the wrong format. Just missing the space between count and decision.

Incorrect:return count + decision;

Correct:return count +" "+ decision;

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