Skip to content
Exercise · Operators and type conversion · lesson 13 of 14

Exercise: hours and minutes

Write two functions. function hoursOf(totalMinutes) returns how many whole hours there are in totalMinutes minutes, and function minutesOf(totalMinutes) returns how many minutes remain on top of those hours.

  • hoursOf(135) → 2
  • minutesOf(135) → 15
  • minutesOf(120) → 0

Constraints: totalMinutes is a whole number from 0 to 100000; less than an hour is 0 whole hours.

Do not add extra imports unless the task says so explicitly.

time.js — javascript
javascript · 8 lines
Ctrl+Enter run · Esc leave editor

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way