Advertisement
Spocoman

06. World Swimming Record

Dec 16th, 2021 (edited)
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function worldSwimmingRecord(input) {
  2.     let record = Number(input[0]);
  3.     let distance = Number(input[1]);
  4.     let secondsToMeter = Number(input[2]);
  5.  
  6.     let score = distance * secondsToMeter + Math.floor(distance / 15) * 12.5;
  7.  
  8.     if (record > score) {
  9.         console.log(`Yes, he succeeded! The new world record is ${score.toFixed(2)} seconds.`);
  10.     } else {
  11.         console.log(`No, he failed! He was ${(score - record).toFixed(2)} seconds slower.`);
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement