The song in seconds
- O(1) · Trivial
- Free
- Python
- JavaScript
- strings
- operations
Problem
A song's length comes written as text, always with two digits on each side of the colon: "04:05" is four minutes and five seconds.
Write a function that takes that text and returns how many seconds it lasts in total, as a number: "04:05" gives 245 and "00:45" gives 45.
Examples
"04:05" → 245
"00:45" → 45
Whole minutes
"12:00" → 720
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def to_seconds(text):
passJavaScript
function toSeconds(text) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.
More O(1) challenges
- The tax already in the pricePython · JavaScript · operations · decimals
- The tiles that fitPython · JavaScript · operations · division
- The twelve-hour clockPython · JavaScript · conditionals · strings
- The usernamePython · JavaScript · strings
- Three for the price of twoPython · JavaScript · operations · division
- What the host paysPython · JavaScript · operations · division