Grading Students

  • + 0 comments

    my version not the best I forget to devide by 5 in place of 10

    function gradingStudents(grades) {
        // Write your code here
        
        return grades.map((grade) => {
            if(grade < 38)
            {
                return grade;
            }
            
            const module = grade % 10;
            const diff = module <= 5 ? (5 - module) : (10 - module);
    
            if(diff < 3)
            {
                return grade + diff;
            }
            
            return grade;
        })
    }