• + 0 comments
    function getGrade(score) {
        let grade;
        // Write your code here
        const ranges = [
            { max: 5, grade: 'F' },
            { max: 10, grade: 'E' },
            { max: 15, grade: 'D' },
            { max: 20, grade: 'C' },
            { max: 25, grade: 'B' },
            { max: 30, grade: 'A' }
        ];
        for(const {max, grade} of ranges){
            if (score <= max) return grade;
        }
    
        return grade;
    }