SHARE
TWEET

Untitled

krustev_84 Feb 27th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onTimeForTheExam(arg) {
  2.   let examHour = Number(arg.shift());
  3.   let examMinute = Number(arg.shift());
  4.   let ariveHour = Number(arg.shift());
  5.   let ariveMinute = Number(arg.shift());
  6.  
  7.   let examTime = examHour * 60 + examMinute;
  8.   let ariveTime = ariveHour * 60 + ariveMinute;
  9.  
  10.   let difference = examTime - ariveTime;
  11.  
  12.   if (difference < 0) {
  13.     console.log("Late");
  14.   } else if (difference <= 30) {
  15.     console.log("On time");
  16.   } else {
  17.     console.log("Early");
  18.   }
  19.  
  20.   if (difference > -60 && difference < 0) {
  21.     console.log(`${Math.abs(difference)} minutes after the start`);
  22.   } else if (difference < -60 && difference < 0) {
  23.     if (Math.abs(difference) % 60 < 10 && difference < 0) {
  24.       console.log(
  25.         `${Math.floor(Math.abs(difference) / 60)}:0${Matt.abs(difference) %
  26.           60} hours after the start`
  27.       );
  28.     } else if (difference < 0) {
  29.       console.log(
  30.         `${Math.floor(Math.abs(difference) / 60)}:${Math.abs(difference) %
  31.           60} hours after the start`
  32.       );
  33.     }
  34.   } else if (difference < 60 && difference > 0) {
  35.     console.log(`${difference} minutes before the start`);
  36.   } else {
  37.     if (difference % 60 < 10 && difference > 0) {
  38.       console.log(
  39.         `${Math.floor(difference / 60)}:0${difference %
  40.           60} hours before the start`
  41.       );
  42.     } else if (difference > 0) {
  43.       console.log(
  44.         `${Math.floor(difference / 60)}:${difference %
  45.           60} hours before the start`
  46.       );
  47.     }
  48.   }
  49. }
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