Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function airplane(arg1, arg2, arg3) {
- let hours = Number(arg1)
- let minutes = Number(arg2)
- let timeForFlight = Number(arg3)
- let totalMinutes = minutes + timeForFlight
- let minutesForTheTime = totalMinutes % 60
- let hoursForTheTime = (totalMinutes - minutesForTheTime) / 60
- // console.log(minutesForTheTime)
- // console.log(hoursForTheTime)
- let timeHours = hours + hoursForTheTime
- if(timeHours > 23) {
- let hoursAfterMidnight = timeHours % 24
- return (hoursAfterMidnight + 'h ' + minutesForTheTime + 'm')
- } else {
- return (timeHours + 'h' + minutesForTheTime + 'm')
- }
- // console.log(typeof(timeHours))
- // console.log(typeof(minutesForTheTime))
- }
- // airplane(["6", "50", "90"])
- airplane("23", "50", "75")
Advertisement
Add Comment
Please, Sign In to add comment