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