Ivankooo1

Exam

Jun 7th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. function Exam(input){
  2. let hourExam = Number(input.shift());
  3. let minutesExam = Number(input.shift());
  4. let hourArrived = Number(input.shift());
  5. let minutesArrived = Number(input.shift());
  6.  
  7. let examtotalMins = hourExam * 60 + minutesExam;//subirat se minutite
  8. let arrtotalMins = hourArrived * 60 + minutesArrived;
  9. let time = examtotalMins - arrtotalMins;
  10.  
  11. if(time < 0){
  12. console.log('Late');
  13. if(time > -60){
  14. console.log(`${Math.abs(time)} minutes after the start`);
  15. }else{
  16. let h = Math.abs(parseInt(time / 60));//chasovete
  17. let m = Math.abs(time % 60);// ostatuk na time sa minutite.
  18. if(m < 10){
  19. console.log(`${h}:0${m} hours after the start`);
  20. }else{
  21. console.log(`${h}:${m} hours after the start`);
  22. }
  23.  
  24. }
  25. }else if(time === 0 || time <= 30){
  26. console.log('On time');
  27. if(time > 0){
  28. console.log(`${time} minutes before the start`);
  29. }
  30. }else {
  31. console.log('Early');
  32. if(time < 60){
  33. console.log(`${time} minutes before the start`);
  34. }else{
  35. let h = parseInt(time/60);
  36. let m = time % 60;
  37. if(m < 10){
  38. console.log(`${h}: 0${m} hours before the start`);
  39. }else{
  40. console.log(`${h}: ${m} hours before the start`);
  41. }
  42. }
  43. }
  44. }
  45. Exam([9,30,9,50]);
  46. Exam([9,00,8,30]);
  47. Exam([16,00,15,00]);
  48. Exam([10,00,10,00]);
Advertisement
Add Comment
Please, Sign In to add comment