Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(record, distance, timeperm ) {
- record = Number(record);
- distance = Number(distance);
- timeperm = Number(timeperm);
- let swimtime = distance * timeperm;
- let addtime = (Math.floor(distance / 15) * 12.5);
- let fulltime = swimtime + addtime;
- if (record < fulltime) {
- let secneeded = Math.abs(fulltime - record);
- console.log(`No, he failed! He was ${secneeded.toFixed(2)} seconds slower.`)
- } else {
- console.log(`Yes, he succeeded! The new world record is ${fulltime.toFixed(2)} seconds.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement