Created
June 16, 2022 07:40
-
-
Save topeogunleye/4dc235aea4fd9681b27a2d88c1f0968f to your computer and use it in GitHub Desktop.
Grading Students
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gradingStudents(grades) { | |
// Write your code here | |
// if grades >= 40 | |
// check if grade - next multiple of 5 is less than 3 | |
// if less than 3 round | |
// else return grade unrounded | |
let results = [] | |
function getNearestMultiple(number, multiple) { | |
return number + (multiple - (number % multiple)); | |
} | |
for (let i = 0; i < grades; i++) { | |
if (grades[i] >= 40) { | |
let muliple = getNearestMultiple(grades[i], 5) | |
if (multiple - grades[i] < 3) { | |
results.push(multiple) | |
} else { | |
results.push(grades[i]) | |
} | |
} else { | |
results.push(grades[i]) | |
} | |
} | |
// console.log(results) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment