You are viewing a single comment's thread. Return to all comments →
My Typescript solution:
function gradingStudents(grades: number[]): number[] { const roundedGrades: number[] = []; const length = grades.length; for (let i = 0; i < length; i++) { const grade = grades[i]; const nextMultipleOf5 = grades[i] + (5 - (grades[i] % 5)); if (grade < 38) { roundedGrades.push(grade); } else if (nextMultipleOf5 - grade < 3) { roundedGrades.push(nextMultipleOf5); } else { roundedGrades.push(grade); } } return roundedGrades; }
Seems like cookies are disabled on this browser, please enable them to open this website
Grading Students
You are viewing a single comment's thread. Return to all comments →
My Typescript solution: