Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hello(input) {
- let recorInSec = +input[0];
- let distanceInM = +input[1];
- let timeS1M = +input[2];
- let timeInSec = distanceInM * timeS1M;
- let bonus15Sec1 = Math.floor(distanceInM / 15);
- let bonus15Sec2 = bonus15Sec1 * 12.5;
- let totaltime = timeInSec + bonus15Sec2;
- let enough = Math.abs(totaltime);
- let notenough = Math.abs(recorInSec - totaltime);
- if (totaltime < recorInSec) {
- console.log(`Yes, he succeeded! The new world record is ${enough.toFixed(2)} seconds.`);
- } else if (totaltime > recorInSec) {
- console.log(`No, he failed! He was ${notenough.toFixed(2)} seconds slower.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment