loading...

Discussion on: Daily Challenge #68 - Grade Book

Collapse
kerrishotts profile image
Kerri Shotts

Here's mine:

const sum = (...nums) => nums.reduce((total, cur) => total + cur, 0);
const meanGrade = (...grades) => sum(...grades) / grades.length;
const letterForGrade = grade => {
    const lastDigit = grade % 10;
    const gradeLetter = Object.entries({90: "A", 80: "B", 70: "C", 60: "D", 0: "F"})
        .sort(([a], [b]) => a < b)
        .find(([minGrade]) => grade >= minGrade)
        [1] + ((lastDigit < 5) ? "-" :
               (lastDigit > 5) ? "+" : "");
    return gradeLetter;
};

Gist: gist.github.com/kerrishotts/559154...

Collapse
casiimin profile image
Casi Imin

Nice Js!