Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(hourExam, minExam, hourArrive, minArrive) {
  2.     hourExam = Number(hourExam);
  3.     minExam = Number(minExam);
  4.     hourArrive = Number(hourArrive);
  5.     minArrive = Number(minArrive);
  6.  
  7.     let hourE = (hourExam * 60) + minExam;
  8.     let hourA = (hourArrive * 60) + minArrive;
  9.     let differrence = (hourE - hourA);
  10.  
  11.     if (differrence > 30) {
  12.  
  13.         if(differrence < 60){
  14.             console.log('Early');
  15.            
  16.             console.log(`${Math.abs(hourA - hourE)} minutes before the start`);
  17.  
  18.         }else {
  19.             let hh = differrence / 60;
  20.             let mm = differrence % 60;
  21.             if(mm ==0 || mm <=9){
  22.                 mm = '0' + differrence % 60;
  23.             }
  24.             console.log('Early');
  25.             console.log(`${Math.floor(hh)}:${mm} hours before the start`);
  26.         }
  27.        
  28.    
  29.  
  30.     } else if (differrence >= 0 && differrence <= 30) {
  31.         console.log('on time');
  32.         console.log(`${Math.abs(hourA - hourE)} minutes before the start`)
  33.        
  34.     }
  35.  
  36.     else  {
  37.         if(differrence < 0 && differrence > -60){
  38.             console.log('late');
  39.             console.log(`${Math.abs(hourA - hourE)} minutes after the start`);
  40.            
  41.            
  42.         }else{
  43.             let hh = Math.abs(differrence / 60);
  44.             let mm = Math.abs(differrence % 60);
  45.             console.log('late');
  46.             console.log(`${Math.floor(hh)}:${mm} hours after the start`);
  47.         }
  48.         //late
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement