Advertisement
Guest User

Untitled

a guest
May 12th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. function solve(hourS, minS, hourA, minA) {
  2.  
  3. hourS=+hourS;
  4. hourA=+hourA;
  5. minS=+minS;
  6. minA=+minA;
  7.  
  8. let rmS= hourS*60+minS;
  9. let rmA= hourA*60+minA;
  10. let late=rmA-rmS;
  11. let early= rmS-rmA;
  12. let hhA=Math.floor((rmA-rmS)/60);
  13. let mindiflate=minA-minS;
  14.  
  15. if (rmS<rmA) {
  16. console.log ("Late");
  17. if (rmS+60>rmA) {
  18. console.log(`${late} minutes after the start`);
  19. } else {
  20. if (minA>=minS) {
  21. console.log (`${hhA}:${mindiflate} hours after the start`)
  22. } else {
  23. mindiflate+=60;
  24. console.log (`${hhA}:${mindiflate} hours after the start`);
  25. }
  26. }}
  27. else if ((rmA+30>=rmS) && (rmS>=rmA)) {
  28. console.log ("On time");
  29. if (rmA!==rmS) {
  30. console.log (`${early} minutes before the start`);
  31. }
  32. }
  33. else if ((rmA+30<rmS) && (rmS>=rmA)) {
  34. console.log ("Early");
  35. if ((early<60) && (early>=10)) {
  36. console.log (`${early} minutes before the start`);
  37. } else if (early>=60) {
  38. let h=Math.floor(early/60);
  39. let m=early%60;
  40.  
  41. if (m<10) {
  42. console.log (`${h}:0${m} hours before the start`);
  43. } else {
  44. console.log (`${h}:${m} hours before the start`);
  45. }
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement