aneliabogeva

OnTimeForExam

Jan 15th, 2021
693
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function squareArea(input){
  2.   let arriveHour = Number(input[0])
  3.   let arriveMinute = Number(input[1])
  4.   let examHour = Number(input[2])
  5.   let examMinute = Number(input[3])
  6.   let hour = 0
  7.   let min = 0
  8.  
  9.   let arriveTimeInMinutes = arriveHour * 60 + arriveMinute
  10.   let examTimeInMinutes = examHour * 60 + examMinute
  11.   let diff = Math.abs(arriveTimeInMinutes - examTimeInMinutes)
  12.  
  13.   if(arriveTimeInMinutes >= examTimeInMinutes){
  14.       hour = Math.floor(diff / 60)
  15.       min = diff % 60
  16.       if(min > 60){
  17.         hour += 1;
  18.         min -= 60
  19.       }
  20.       if(hour == 0 && min <= 30){
  21.         console.log(`On time`)
  22.         if (min != 0){
  23.           console.log(`${min} minutes before the start`)
  24.         }
  25.       }else if(min > 30 || hour > 0){
  26.         console.log(`Early`)
  27.         if(hour == 0){
  28.           console.log(`${min} minutes before the start`)
  29.         }else if(hour > 0){
  30.           if (min < 10){
  31.             console.log(`${hour}:0${min} hours before the start`)
  32.           }else{
  33.             console.log(`${hour}:${min} hours before the start`)
  34.           }
  35.         }
  36.       }
  37.   }else{
  38.     hour = Math.floor(diff / 60)
  39.       min = diff % 60
  40.       if(min > 60){
  41.         hour += 1;
  42.         min -= 60
  43.       }
  44.     console.log(`Late`)
  45.     if(hour == 0){
  46.       if (min < 10){
  47.         console.log(`${min} minutes after the start`)
  48.       }else{
  49.         console.log(`${min} minutes after the start`)
  50.       }
  51.     }else if(hour > 0){
  52.       if (min < 10){
  53.         console.log(`${hour}:0${min} hours after the start`)
  54.       }else{
  55.         console.log(`${hour}:${min} hours after the start`)
  56.       }
  57.     }
  58.   }
  59. }
  60.  
  61.  
  62.  
RAW Paste Data