Advertisement
DraconiusNX

Untitled

Sep 25th, 2022
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function worldSwimmingRecord(input){
  2.     let recordSec = Number(input[0]);
  3.     let distans = Number(input[1]);
  4.     let timeSec = Number(input[2]);
  5.    
  6.     let mustSwim = distans * timeSec;
  7.     let waterResistance = Math.floor(distans / 15) * 12.5;
  8.     let totalTime = mustSwim + waterResistance;
  9.     let timeShortage = Math.abs(totalTime - recordSec);
  10.  
  11.     if (recordSec < totalTime) {
  12.         console.log(`No, he failed! He was ${timeShortage.toFixed(2)} seconds slower.`);
  13.    
  14.     } else {
  15.         console.log(`Yes, he succeeded! The new world record is ${totalTime.toFixed(2)} seconds.`);
  16.     }
  17. }
  18. worldSwimmingRecord(["55555.67",
  19.  
  20. "3017",
  21.  
  22. "5.03"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement