Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let month = input[0];
- let countOfNights = +input[1];
- let studioSum = 0;
- let apartmentSum = 0;
- if (month === 'May' || month === 'October') {
- if ( countOfNights <= 7 ) {
- studioSum = countOfNights * 50;
- } else if (countOfNights > 7 && countOfNights < 14) {
- studioSum = countOfNights * 50;
- studioSum = studioSum - (studioSum * (5 / 100));
- } else {
- studioSum = countOfNights * 50;
- studioSum = studioSum - (studioSum * (30 / 100));
- }
- apartmentSum = countOfNights * 65;
- } else if (month === 'June' || month === 'Semptember') {
- studioSum = countOfNights * 75.20;
- if ( countOfNights > 14) {
- studioSum = studioSum - (studioSum * (20 / 100));
- }
- apartmentSum = countOfNights * 68.70;
- } else if (month === 'July' || month === 'August') {
- studioSum = countOfNights * 76;
- apartmentSum = countOfNights * 77;
- }
- if (countOfNights > 14) {
- apartmentSum = apartmentSum - (apartmentSum * (10 / 100));
- }
- console.log(`Apartment: ${apartmentSum.toFixed(2)} lv.`);
- console.log(`Studio: ${studioSum.toFixed(2)} lv.`);
- }
- solve([
- 'June',
- '14',
- ]);
Advertisement
Add Comment
Please, Sign In to add comment