Advertisement
kstoyanov

Untitled

Feb 20th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. problem 07. World Swimming Record
  2.  
  3. function solve(arg){
  4.  
  5.     let theRecordInSeconds = Number(arg.shift());
  6.     let theDistanceInMeters = Number(arg.shift());
  7.     let timeInSeconds = Number(arg.shift());
  8.  
  9.     let swimsInSeconds = theDistanceInMeters * timeInSeconds;
  10.     let swimmingDelay = Math.floor(theDistanceInMeters / 15) * 12.5;
  11.     let totalTime = swimsInSeconds + swimmingDelay;
  12.     let isItTime  = theRecordInSeconds <= totalTime ? totalTime - theRecordInSeconds : totalTime ;
  13.  
  14.    
  15.  
  16.     if(theRecordInSeconds > totalTime){
  17.  
  18.         console.log(`Yes, he succeeded! The new world record is ${(isItTime).toFixed(2)} seconds.`);
  19.  
  20.     }else{
  21.  
  22.         console.log(`No, he failed! He was ${isItTime.toFixed(2)} seconds slower.`);
  23.  
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement