tedo1111

80/100

Sep 12th, 2023
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function hello(input) {
  2. let recorInSec = +input[0];
  3. let distanceInM = +input[1];
  4. let timeS1M = +input[2];
  5.  
  6. let timeInSec = distanceInM * timeS1M;
  7.  
  8. let bonus15Sec1 = Math.floor(distanceInM / 15);
  9. let bonus15Sec2 = bonus15Sec1 * 12.5;
  10.  
  11. let totaltime = timeInSec + bonus15Sec2;
  12.  
  13. let enough = Math.abs(totaltime);
  14. let notenough = Math.abs(recorInSec - totaltime);
  15.  
  16. if (totaltime < recorInSec) {
  17. console.log(`Yes, he succeeded! The new world record is ${enough.toFixed(2)} seconds.`);
  18. } else if (totaltime > recorInSec) {
  19. console.log(`No, he failed! He was ${notenough.toFixed(2)} seconds slower.`);
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment