We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functiongradingStudents(grades){// less than 38 is automatically failed// if the difference b/w original marks and rounded original marks by closest multiple of 5// is less than 3, then round off to rounded marks. If not, original marks remain the same.letminMarks=38;letlengthOfGrades=grades.length;letfinalArray=[];letmult5=0;console.log(grades);// assuming grades -> [73,67,38,33]for(leti=0;i<lengthOfGrades;i++){// fail because grades LT 38if(grades[i]<minMarks){finalArray.push(grades[i]);}else{// grades are GTE 38// finding the multiples of 5mult5=Math.ceil(grades[i]/5);// 73/5 => 14.6 => ceil(14.6) => 15mult5*=5;// to get the multiple of 5 closest to grade 15*5=>75if(mult5-grades[i]<3){finalArray.push(mult5);}else{finalArray.push(grades[i]);}}}returnfinalArray;}
`
undefined
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Grading Students
You are viewing a single comment's thread. Return to all comments →
` undefined