Advertisement
kstoyanov

01. Bonus Scoring System mid Exam js fundamentals

Jul 4th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function exam(args) {
  2.   const input = args.map((element) => Number(element));
  3.   const students = input.shift();
  4.   const lectures = input.shift();
  5.   const initBonus = input.shift();
  6.   let highestScore = 0;
  7.   let totalBonus = 0;
  8.   for (let i = 0; i < students; i++) {
  9.     const student = input[i];
  10.     if (student <= lectures) {
  11.       if (student > highestScore) {
  12.         highestScore = student;
  13.         totalBonus = Math.ceil((student / lectures) * (5 + initBonus));
  14.       }
  15.     }
  16.   }
  17.   console.log(`Max Bonus: ${totalBonus}.`);
  18.   console.log(`The student has attended ${highestScore} lectures.`);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement