Last active
October 16, 2018 17:09
-
-
Save ryanpcmcquen/5f3f17b5cd036e972d4fbd961e065ffe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const gradingStudents = (grades) => { | |
return grades.map( | |
grade => { | |
switch (true) { | |
case grade < 38: | |
return grade | |
case (grade % 5) > 2: | |
return grade + (5 - (grade % 5)) | |
default: | |
return grade | |
// Brute force: | |
/* | |
case String(grade + 1).slice(-1) === '0': | |
return grade + 1 | |
case String(grade + 2).slice(-1) === '0': | |
return grade + 2 | |
case String(grade + 1).slice(-1) === '5': | |
return grade + 1 | |
case String(grade + 2).slice(-1) === '5': | |
return grade + 2 | |
default: | |
return grade | |
*/ | |
} | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment