Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

333
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!