I tried to solve the Hackerank challenge of grading students.
whereby my codes work in my local system, yet hackerank does not pass it?
Please, can someone help?
Below is the code I figured out to solve the problem.

function gradingStudents(grades) {
// Write your code here
if (grades < 38){
return grades
} else {
for (let i = 40; i <= 100; i = i + 5){
while ( i - grades < 5 && i - grades > 0){
if (i - grades < 3){
return i
} else{
return grades
}
}
}
}
}

Greetings!
I found a solution to the challenge. It did pass the test.
The problem only arises when I submit the solution.
I get to score 7/12. Meaning I failed in 5 cases. I don’t know why.
Below is the code I developed. Please any ideas as to why the code won’t work in all cases?
…
…

function gradingStudents(grades) {
// Write your code here
let b =

for (let i = 0; i < grades.length; i++){
for (i of grades){
if (i < 38 ) {
b.push(i)
}else {
if ((parseInt(i) % 5) < 3){
b.push(parseInt(i))
} else{
let c = parseInt(i) + (5-(parseInt(i) % 5))
b.push(c)
}
}
}
}
return b
}