Advertisement
Liliana797979

mountain run

Dec 21st, 2020
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function mountainRun(arg1, arg2, arg3) {
  2.     let recordInSeconds = Number(arg1);
  3.     let distance = Number(arg2);
  4.     let timeInSeconds = Number(arg3);
  5.  
  6.     distance = distance * timeInSeconds;
  7.     let slope = (distance / 50) * 30;
  8.     let totalTime = distance + slope;
  9.  
  10.     if (totalTime > recordInSeconds) {
  11.         console.log(`Yes! The new record is ${(totalTime).toFixed(2)} seconds.`);
  12.        
  13.     } else if (totalTime < recordInSeconds) {
  14.         console.log(`No! He was ${(totalTime - recordInSeconds).toFixed(2)} seconds slower.`);
  15.     }
  16. }
  17.  
  18. mountainRun("10164", "1400", "25");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement