Advertisement
SvilenHristov

timePlusFiftheen

Feb 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function timePlusFiftheen([hours, minutes]) {
  2.     hours = Number(hours);
  3.     minutes = Number(minutes);
  4.    
  5.     let minsPlusFiftheen = minutes + 15;
  6.     minsPlusFiftheen = '0' + (minsPlusFiftheen % 60);
  7.     minsPlusFiftheen = minsPlusFiftheen.slice(-2);
  8.     let hs = hours;
  9.  
  10.     if (minsPlusFiftheen > 59) {
  11.         let hs = hs + 1;
  12.         minsPlusFiftheen = minsPlusFiftheen - 60;
  13.     } else if (hs == 24) {
  14.         hours = 0;
  15.         hs = 0;
  16.     } else if (hours > 23) {
  17.         hours = 0;
  18.     }
  19.     console.log(`${hs}:${minsPlusFiftheen}`);
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement