// Score is an integer or float that is based on 0 - 100 scale.
function letterGrade($score) {
if ($score >= 90) { return "A"; }
else if ($score >= 80) { return "B"; }
else if ($score >= 70) { return "C"; }
else if ($score >= 60) { return "D"; }
else { return "F"; }
}
Posted: March 18, 2023
Return to the snippets listing