Ledger Nano X - The secure hardware wallet
SHARE
TWEET

On Time for Exam

a guest Apr 3rd, 2020 199 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.             }  
  48.  
  49.     }   if((time === 'On time') && (examMinutes === arriveMinutes)) {
  50.         console.log(`On time`);
  51.        
  52.     } else if(time === 'On time' && minsDifference <= 30) {
  53.         minsDifference = allExamMins - allArriveMins;
  54.         console.log('On time');
  55.         console.log(`${minsDifference} minutes before the start`);
  56.        
  57.     } if(time === 'Early') {
  58.         if(allExamMins - allArriveMins < 60) {  
  59.             minsDifference = allExamMins - allArriveMins;
  60.             console.log(`${minsDifference} minutes before the start`);
  61.        
  62.         } else {
  63.             hours = examHour - arriveHour;
  64.             minutes = examMinutes - arriveMinutes;
  65.             if(minutes < 10){
  66.             console.log(`${hours}:0${minutes} hours before the start`);
  67.         } else {
  68.             console.log(`${hours}:${minutes} hours before the start`);
  69.         }
  70.         }
  71.     }    
  72. }
RAW Paste Data
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