Advertisement
Todorov_Stanimir

04. Time to Walk Exercise: Syntax, Functions and Statements

Sep 19th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function timeToWalk(steps, length, speed) {
  2.     let distance = steps * length;
  3.     let time = Math.ceil(distance / (speed * 1000 / 3600) + Math.floor(distance / 500) * 60);
  4.     let hours = Math.floor(time / 3600);
  5.     let minutes = Math.floor((time - hours * 3600) / 60);
  6.     let seconds = time - hours*3600 - minutes*60;
  7.     console.log(`${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`)
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement