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

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

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 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