plamen1982

airplane

Apr 1st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function airplane(args) {
  2. let hours = Number(args[0])
  3. let minutes = Number(args[1])
  4. let timeForFlight = Number(args[2])
  5.  
  6. let totalMinutes = minutes + timeForFlight
  7. let minutesForTheTime = totalMinutes % 60
  8. let hoursForTheTime = (totalMinutes - minutesForTheTime) / 60
  9. // console.log(minutesForTheTime)
  10. // console.log(hoursForTheTime)
  11. let timeHours = hours + hoursForTheTime
  12. if(timeHours > 23) {
  13. let hoursAfterMidnight = timeHours % 24
  14. return (`${hoursAfterMidnight}h ${minutesForTheTime}m`)
  15. } else {
  16. return (`${timeForFlight}h ${minutesForTheTime}m`)
  17. }
  18. // console.log(typeof(timeHours))
  19. // console.log(typeof(minutesForTheTime))
  20. }
Advertisement
Add Comment
Please, Sign In to add comment