Today's challenge requires you to calculate one's running pace.
For example:
runningPace(distance, time)
distance - A float with the number of kilometres
time - A string containing the time it took to travel the distance; it will always be minutes:secondsThe function should return the pace, "5:20" means it took 5 minutes and 20 seconds to travel one kilometre.
Happy Coding!
This challenge comes from jtauri on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (9)
Here it goes!
Python
Not brilliant but...
Here is the simple solution with JavaScript:
Python :
Ruby <3
function runningPace(distance, time){
const dist = distance * 1000; //in meters
const timeInSecond =parseInt(time.split(':')[0]) * 60 + parseInt(time.split(':')[1]); //in seconds
const pace = dist / timeInSecond;
return pace
I know these don't get many likes, but I really appreciate these. Like really appreciate them!