Advertisement
Spocoman

Mountain Run

Jan 5th, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function mountainRun(input) {
  2.    
  3.     let record = Number(input[0]);
  4.     let meters = Number(input[1]);
  5.     let secondPerMeter = Number(input[2]);
  6.  
  7.     let sum = meters * secondPerMeter + Math.floor(meters / 50) * 30;
  8.    
  9.     if (sum < record) {
  10.         console.log(` Yes! The new record is ${sum.toFixed(2)} seconds.`);
  11.     } else {
  12.         console.log(`No! He was ${(sum - record).toFixed(2)} seconds slower.`);
  13.     }
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement