SHARE
TWEET

World Swimming Record

djemchaushev Nov 22nd, 2019 (edited) 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function record (input){
  2.     let recordInSeconds = Number(input.shift());
  3.     let distance = Number(input.shift());
  4.     let timeInSeconds = Number(input.shift());
  5.     let swimMeters = distance * timeInSeconds;
  6.     let resistance = Math.floor(distance / 15);
  7.     let delay = resistance * 12.5;
  8.     let totalSeconds = swimMeters + delay;
  9.     let result = Math.abs(totalSeconds - recordInSeconds);
  10.     if (recordInSeconds <= totalSeconds){
  11.         console.log(`No, he failed! He was ${result.toFixed(2)} seconds slower.`)
  12.     } else {
  13.         console.log(`Yes, he succeeded! The new world record is ${totalSeconds.toFixed(2)} seconds.`);
  14.     }
  15.    
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top