← Back to challenges

Calculate Elapsed Time

JavaScriptHardnumbersstrings

Instructions

Create a function that takes a timestamp for the start time sa and stop time st in HH:MM:SS format and returns the measured amount of elapsed time between start and stop times.

Examples

elapsedTime("11:00:00", "12:00:00") ➞ "01:00:00"

elapsedTime("13:01:43", "21:41:57") ➞ "08:40:14"

elapsedTime("17:34:43", "17:34:42") ➞ "23:59:59"

Notes

  • All times will be provided in 24 Hrs format.
  • Consider Elapsed time will always be less than 24 Hrs.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.