← Back to challenges

Clock Hands

JavaScriptHardmathnumbers

Instructions

Create a function whose argument is the time in 12 hour format (hh:mm:ss). The function returns the smaller angle between the hour and minute hands in degrees, rounded to three decimal points.

Examples

clock("12:00:00") ➞ 0.0

clock("12:15:00") ➞ 82.5

clock("12:32:44") ➞ 179.967

clock("03:33:33") ➞ 94.525

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.