G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 4th, 2020 150 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function exam(examHour, examMinutes, arriveHour, arriveMinutes) {
  2.  
  3.     examHour = Number(examHour);
  4.     examMinutes = Number(examMinutes);
  5.     arriveHour = Number(arriveHour);
  6.     arriveMinutes = Number(arriveMinutes);
  7.  
  8.     let allExamMins = ((examHour * 60) + examMinutes);
  9.     let allArriveMins = ((arriveHour * 60) + arriveMinutes);
  10.     let time = '';
  11.     let hours = 0;
  12.     let minutes = 0;
  13.     let minsDifference = 0;
  14.  
  15.  
  16.     if (allArriveMins > allExamMins) {
  17.         time = 'Late';
  18.         console.log(time);
  19.  
  20.     } else if (allExamMins - allArriveMins <= 30) {
  21.         time = 'On time';
  22.  
  23.     } else {
  24.         time = 'Early';
  25.         console.log(time);
  26.     }
  27.  
  28.     let result = Math.abs(allArriveMins - allExamMins);
  29.  
  30.     if (time === 'Late') {
  31.         if (examHour <= arriveHour) {
  32.             hours = arriveHour - examHour;
  33.             minutes = arriveMinutes - examMinutes;
  34.             minsDifference = allArriveMins - allExamMins;
  35.         }
  36.         if (minsDifference < 60) {
  37.             console.log(`${minsDifference} minutes after the start`);
  38.  
  39.         } else if (minsDifference >= 60 && minutes < 10) {
  40.             console.log(`${hours}:0${minutes} hours after the start`);
  41.  
  42.         } else {
  43.             minutes = minsDifference % 60;
  44.             console.log(`${hours}:${minutes} hours after the start`);
  45.         }
  46.  
  47.     } if ((time === 'On time') && (examMinutes === arriveMinutes)) {
  48.         console.log(`On time`);
  49.  
  50.     } else if (time === 'On time' && minsDifference <= 30) {
  51.         minsDifference = allExamMins - allArriveMins;
  52.         console.log('On time');
  53.         console.log(`${minsDifference} minutes before the start`);
  54.  
  55.     } if (time === 'Early') {
  56.         if (allExamMins - allArriveMins < 60) {
  57.             minsDifference = allExamMins - allArriveMins;
  58.             console.log(`${minsDifference} minutes before the start`);
  59.  
  60.         } else {
  61.             hours = examHour - arriveHour;
  62.             minutes = examMinutes - arriveMinutes;
  63.             if (minutes < 10) {
  64.                 console.log(`${hours}:0${minutes} hours before the start`);
  65.             }
  66.         }
  67.         }else {
  68.             console.log(`${hours}:${minutes} hours before the start`);
  69.  
  70.     }
  71. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top