Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bonusScore(studentsCount,lecturesCount,additionalBonus,input) {
  2.    
  3.     let highest = 0;
  4.     let attendedLectures = 0;
  5.  
  6.     for (let i = 0; i < studentsCount; i++) {
  7.  
  8.         let attendancy = input.shift();
  9.         let totalBonus = Math.round(attendancy / lecturesCount * (5 + additionalBonus));
  10.         if (totalBonus >= highest) {
  11.             highest = totalBonus;
  12.             attendedLectures = attendancy;
  13.         }
  14.     }
  15.     console.log(`Max Bonus: ${highest}.`);
  16.     console.log(`The student has attended ${attendedLectures} lectures.`);
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement