plamen1982

airplane.js

Apr 1st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. function airplane(arg1, arg2, arg3) {
  2. let hours = Number(arg1)
  3. let minutes = Number(arg2)
  4. let timeForFlight = Number(arg3)
  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 (timeHours + 'h' + minutesForTheTime + 'm')
  17. }
  18. // console.log(typeof(timeHours))
  19. // console.log(typeof(minutesForTheTime))
  20. }
  21. // airplane(["6", "50", "90"])
  22. airplane("23", "50", "75")
Advertisement
Add Comment
Please, Sign In to add comment