Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function exam(args) {
- const input = args.map((element) => Number(element));
- const students = input.shift();
- const lectures = input.shift();
- const initBonus = input.shift();
- let highestScore = 0;
- let totalBonus = 0;
- for (let i = 0; i < students; i++) {
- const student = input[i];
- if (student <= lectures) {
- if (student > highestScore) {
- highestScore = student;
- totalBonus = Math.ceil((student / lectures) * (5 + initBonus));
- }
- }
- }
- console.log(`Max Bonus: ${totalBonus}.`);
- console.log(`The student has attended ${highestScore} lectures.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement