gradingStudents

    0

    0

    The gradingStudent function takes in a grades array as an input and returns an array of grades. The gradingStudent function will look at each grade in the grades array and will compare the grade to 38. If the grade is less than 38, the grade will be pushed into the gradesFinal array. If the grade is 3 or less, the grade will be pushed into the gradesFinal array regardless. If the grade is greater than 3, the grade will be pushed into the gradesFinal array only if it is not less than the current grade in the gradesFinal array. If the grade is less than the current grade in the gradesFinal array, then the grade will be set to the current grade in the gradesFinal array.

    function gradingStudents(grades) {
      let gradesFinal = [];
        for(let i=0; i<grades.length; i++){
            if(grades[i]< 38){
                gradesFinal.push(grades[i]);
            }else if(((Math.ceil(grades[i]/5)*5) - grades[i]) < 3){
                gradesFinal.push(Math.ceil(grades[i]/5)*5);
            }else if(((Math.ceil(grades[i]/5)*5) - grades[i]) >= 3){
                gradesFinal.push(grades[i]);
            }
        }
        return gradesFinal;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.