Skip to content

Instantly share code, notes, and snippets.

@see-why
Created January 4, 2022 07:30
Show Gist options
  • Save see-why/9521fabaabf6e893b6eed4d4c093897e to your computer and use it in GitHub Desktop.
Save see-why/9521fabaabf6e893b6eed4d4c093897e to your computer and use it in GitHub Desktop.
//Hackerank challenge...https://www.hackerrank.com/challenges/grading/problem?isFullScreen=true
function gradingStudents(grades) {
// Write your code here
const newArray = grades.map((item) => {
if(item >= 38 ){
const quotient = Math.floor(item / 5);
const nextMultiple = (quotient + 1) * 5;
item = (nextMultiple - item) < 3 ? nextMultiple : item;
}
return item
})
return newArray
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment