Advertisement
JOHNYTHEWINNER

Voleyball games

May 7th, 2020
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function coleyball(...input) {
  3.     let year = input[0];
  4.     let p = parseInt(input[1]);
  5.     let h = parseInt(input[2]);
  6.     let weekends = 48;
  7.     let weekendsinSofia = weekends - h;
  8.     let games = 0;
  9.     // calcualting weekends in Sofia:
  10.     games += weekendsinSofia * 3 / 4;
  11.     // calculating weekends in the other town:
  12.     games += h;
  13.     // calcualting rest days
  14.     games += 2 * p / 3;
  15.     // calculating extra games in leap year:
  16.     if (year === 'leap') {
  17.         games *= 1.15;
  18.     }
  19.     console.log(`${Math.floor(games)}`)
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement