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

251
Vistas
Hackerrank Challenge- The Hurdle Race. What I am I doing wrong?

so I am working on a HarckerRank Challenge called "The Hurdle Race". I have two ways I completed the challenge in my IDE but it only passes two test cases when I put it in the IDE in HackerRank. When I take one of the case tests and put it in my own IDE I get the correct result. Am I missing something? Is my code incorrect? Below are my codes. enter image description here

// 1st:
function hurdleRace(k, height) {
  let maxH = Math.max.apply(null, k);
  let iGotTheHops = 0;
  console.log(maxH);

  if (height < maxH) {
    console.log(maxH - height);
    return maxH - height;
  } else {
    console.log(0);
    return iGotTheHops;
  }
}

// 2nd:
function hurdleRace2(k, height) {
  // Write your code here

  let maxHight = k[0];
  let iGotHops = 0;

  for (let i = 0; i < k.length; i++) {
    if (k[i] > maxHight) {
      maxHight = k[i];
    }
  }

  if (height < maxHight) {
    console.log(maxHight - height);
    return maxHight - height;

  } else {
    console.log(iGotHops);
    return iGotHops;
  }
}

hurdleRace([1,6,3,5,2],4)
hurdleRace2([1,6,3,5,2],4)

This is the test it flags as incorrect. States that my return is 0.

about 4 years ago · Juan Pablo Isaza
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