emotrend

ужас

Jan 17th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. function solve(stepsCount, footPrint, kmh) {
  2.  
  3. let distanceInM = stepsCount * footPrint;
  4.  
  5. let speedInS = kmh / 3.6;
  6.  
  7. let timeS = Math.round(distanceInM / speedInS);
  8.  
  9. let rest = Math.floor(distanceInM / 500);
  10. timeS += rest * 60;
  11.  
  12. let seconds = timeS % 60;
  13. let hour = Math.floor((timeS - seconds) / 3600);
  14. let minutes = (timeS - seconds) / 60;
  15.  
  16. function format(hour, minutes, seconds) {
  17. if (hour < 10) {
  18. hour = "0" + hour;
  19. }
  20. if (minutes < 10) {
  21. minutes = "0" + minutes;
  22. }
  23. if (seconds < 10) {
  24. seconds = "0" + seconds;
  25. }
  26.  
  27. console.log(`${hour}:${minutes}:${seconds}`);
  28. }
  29.  
  30. format(hour, minutes, seconds);
  31. }
  32. solve(4000, 0.60, 5);
Advertisement
Add Comment
Please, Sign In to add comment