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

336
Vistas
Grading Students Hackerrank challenge return expected?

Anyone who is familiar with the Grading students challenge on Hackerank, please help me understand why this code is not passing.

function gradingStudents(grades) {
  let args = [...arguments];
  const round5 = (x) => {
    return Math.ceil(x / 5) * 5;
  }
  for (let i = 1; i < args.length; i++) {
    if (round5(args[i]) - args[i] < 3 && args[i] >= 38) {
      args[i] = round5(args[i])
    }
  }
  args.shift()
  return args.join('\n') + '\n'
//return args
//return args.join(' ')
}

I am losing my mind. I have tried all sorts of returns and none works.

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

0

Looks like you thought that both the number of students and the grades are being passed to the gradingStudents function, but actually only a single argument is being passed i.e. an array containing the grades of the students.

So, no need to use arguments, you can directly use the grades array. And also you simply need to return the updated grades array from the function, you don't need to worry about output formatting.

function gradingStudents(grades) {
  const round5 = (x) => {
    return Math.ceil(x / 5) * 5;
  };
  for (let i = 0; i < grades.length; i++) {
    if (round5(grades[i]) - grades[i] < 3 && grades[i] >= 38) {
      grades[i] = round5(grades[i]);
    }
  }
  return grades;
}

console.log(gradingStudents([73, 67, 38, 33]));

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