Home My space log
Language EN (English)

Add two video lengths

JavaScript Advanced astronaut ages teen+ From CS Unplugged

The problem

Video lengths are written "hours:minutes:seconds", like "0:32:21". Write a function addDurations(a, b) that adds two lengths and gives back the total in the same form, with no extra zeros. Example: "0:32:21" + "0:33:20" is "1:5:41".

You will practice: splitting text, remainder (%), whole-number division, units of time

Mode

Press Tab to indent. Press Esc and then Tab to move on to the next button.

Your code runs in your browser. We do not receive it or save it.

Test results

      What your code printed

      
          

      CC BY-SA 4.0

      Adapted from a CS Unplugged programming challenge by the University of Canterbury Computer Science Education Research Group, licensed CC BY-SA 4.0.

      Original challenge · License: CC BY-SA 4.0

      Changes: Rewritten in our own words as a function with tests, hints and steps, in Python and JavaScript, by Open Cosmos. This version is also CC BY-SA 4.0.