Advertisement
Spocoman

Cat Training Attendance

Jan 8th, 2022
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function catTrainingAttendance(input) {
  2.  
  3.     let startHours = Number(input[0]);
  4.     let checkHours = Number(input[1]);
  5.     let checkMinutes = Number(input[2]);
  6.     let dayOfWeek = input[3];
  7.  
  8.     let bonusPoints = 0;
  9.  
  10.     if (checkHours < startHours && checkHours <= (startHours - 1)) {
  11.         bonusPoints = 1.5;
  12.     } else if (checkHours === startHours && checkMinutes <= 30) {
  13.         bonusPoints = 1;
  14.     } else if ((checkHours === startHours && checkMinutes > 30) || checkHours <= (startHours + 4)) {
  15.         bonusPoints = 0.5;
  16.     }
  17.     switch (dayOfWeek) {
  18.         case "Monday":
  19.         case "Wednesday":
  20.         case "Friday":
  21.             bonusPoints += 0.6;
  22.             break;
  23.         case "Tuesday":
  24.         case "Thursday":
  25.         case "Saturday":
  26.             bonusPoints += 0.8;
  27.             break;
  28.         case "Sunday":
  29.             bonusPoints += 2;
  30.             break;
  31.     }
  32.     console.log(`${bonusPoints.toFixed(2)}`);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement