-Enigmos-

lunchBreak.js

Oct 9th, 2021 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lunchBreak(input) {
  2.     let tvShowName = input[0];
  3.     let tvShowLenght = Number(input[1]);
  4.     let breakTime = Number(input[2]);
  5.  
  6.     if (Number.isInteger(tvShowLenght) && Number.isInteger(breakTime)) {
  7.         if (tvShowLenght >= 10 && tvShowLenght <= 90 && breakTime >= 10 && breakTime <= 120 && tvShowLenght) {
  8.             let lunchTime = breakTime / 8;
  9.             let relaxTime = breakTime / 4;
  10.             let timeForTvShow = breakTime - (lunchTime + relaxTime);
  11.             let remainingTime = Math.ceil(Math.abs(timeForTvShow - tvShowLenght));
  12.    
  13.             if (timeForTvShow >= tvShowLenght) {
  14.                 console.log(`You have enough time to watch ${tvShowName} and left with ${remainingTime} minutes free time.`);
  15.             } else {
  16.                 console.log(`You don't have enough time to watch ${tvShowName}, you need ${remainingTime} more minutes.`);
  17.            }
  18.        }
  19.    }
  20. }
  21.  
  22. lunchBreak(["Teen Wolf", "48", "60"]);
Add Comment
Please, Sign In to add comment