Advertisement
Guest User

Untitled

a guest
May 26th, 2019
865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function time(input) {
  2.     let startHour = Number(input.shift());
  3.     let startMin = Number(input.shift());
  4.  
  5.     let timeInMin = startHour * 60 + startMin;
  6.  
  7.     let timePlus15 = timeInMin + 15;
  8.  
  9.     let finalHour = parseInt(timePlus15 / 60);
  10.     let finalMin = timePlus15 % 60;
  11.  
  12.     if (finalHour >= 24) {
  13.         finalHour -= 24;
  14.     }
  15.  
  16.     if (finalMin < 10) {
  17.         console.log(`${finalHour}:0${finalMin}`);
  18.     } else {
  19.         console.log(`${finalHour}:${finalMin}`);
  20.     }
  21. }
  22. time([12,55]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement