Advertisement
dimoBs

01. Bonus Scoring System

Feb 21st, 2021
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. function solve(array) {
  2.  
  3. array = array.map(x => Number(x));
  4. let students = array.shift();
  5. let courseLectures = array.shift();
  6. let bonusInitial = array.shift();
  7. let maxBonus = 0;
  8. let totalBonus = 0;
  9.  
  10. for (let i = 0; i < students; i++) {
  11. let studentAttendances = array[i];
  12. if (studentAttendances <= courseLectures) {
  13. if (studentAttendances > maxBonus) {
  14. maxBonus = studentAttendances;
  15. totalBonus = Math.ceil(maxBonus / courseLectures * (5 + bonusInitial));
  16. }
  17. }
  18. }
  19. console.log(`Max Bonus: ${totalBonus}.`);
  20. console.log(`The student has attended ${maxBonus} lectures.`);
  21. }
  22. solve(['5', '25', '30','12', '19', '24','16', '20'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement