desito07

15 + Minutes

Jan 27th, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. function Time(input){
  2. let starthour = Number(input.shift());
  3. let startminutes = Number(input.shift());
  4.  
  5. let timeinminutes = starthour * 60 + startminutes;
  6. //startminutes += starthour * 60
  7. // startminutes += 15;
  8.  
  9. let timeplus15 = timeinminutes + 15;
  10. let finalhour = Math.floor(timeplus15 / 60);
  11. let finalminutes = timeplus15 % 60;
  12.  
  13. if( finalhour >= 24){
  14. finalhour -=24;
  15. }
  16. if (finalminutes < 10) {
  17. console.log(`${finalhour}:0${finalminutes}`);
  18. } else {
  19. console.log(`${finalhour}:${finalminutes}`);
  20. }
  21. }
  22. Time(["1","46"]);
Advertisement
Add Comment
Please, Sign In to add comment