Advertisement
milengerov

04. time-to-walk

May 19th, 2020
1,034
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(steps, footprintLength, speed){
  2.     let distance = steps * footprintLength
  3.    
  4.    
  5.     let seconds = distance / (speed / 3.6) + Math.floor(distance / 500) *60;
  6.    
  7.     let minutes = Math.floor(seconds / 60);
  8.     seconds -= minutes * 60;
  9.     let hours = Math.floor(minutes / 60);
  10.     minutes -= hours * 60;
  11.  
  12.     console.log(`${String(hours).padStart(2, 0)}:${String(minutes).padStart(2, 0)}:${seconds.toFixed(0).padStart(2, 0)}`);
  13.    
  14.  
  15.    
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement