Advertisement
Guest User

01. Bonus Scoring System

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