Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bonusScore(input) {
- let studentsCount = Number(input.shift());
- //console.log(studentsCount);
- let lecturesCount = Number(input.shift());
- //console.log(lecturesCount);
- let bonus = Number(input.shift());
- //console.log(bonus);
- let highestScore = 0;
- let totalBonus = 0;
- for (let i = 0; i < studentsCount; i++) {
- let student = Number(input[i]);
- //console.log(student);
- if (student <= lecturesCount) {
- if (student > highestScore) {
- highestScore = student;
- totalBonus = Math.ceil(highestScore / lecturesCount) * (5 + bonus);
- }
- }
- }
- console.log(`Max Bonus: ${totalBonus}.`);
- console.log(`The student has attended ${highestScore} lectures.`);
- }
- bonusScore([
- '5', '25', '30',
- '12', '19', '24',
- '16', '20'
- ]);
Advertisement
Add Comment
Please, Sign In to add comment