georgiev955

Lunch Break

Feb 19th, 2023
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let name = input[0];
  3.     let duration = Number(input[1]);
  4.     let breakTime = Number(input[2]);
  5.     let lunchTime = breakTime/8;
  6.     let relaxTime = breakTime/4;
  7.     let timeLeft = breakTime - lunchTime - relaxTime;
  8.     if (timeLeft >= duration) {
  9.         console.log(`You have enough time to watch ${name} and left with ${Math.ceil(timeLeft-duration)} minutes free time.`);
  10.     } else {
  11.         console.log(`You don't have enough time to watch ${name}, you need ${Math.ceil(duration-timeLeft)} more minutes.`);
  12.    }
  13.  
  14. }
Advertisement
Add Comment
Please, Sign In to add comment