Проблем със задача Хотелска стая от По-сложни проверки, Judge gives NaN?
function solve(countNights, month) {
countNights = Number(countNights);
let apartment = 0;
let studio = 0;
if (month === `May` || month === `October`) {
if (countNights <= 7) {
apartment = 65;
studio = 50;
} else if (countNights <= 14) {
apartment = 65;
studio = 50 * 0.95;
} else {
studio = 50 * 0.8;
apartment = 50 * 0.9;
}
} else if (month === `June` || `September`) {
apartment = 68.7;
studio = 75.2;
} if (countNights > 14) {
studio = 75.2 * 0.8;
apartment = apartment * 0.1;
} else if (month === `July` || month === `August`) {
studio = 76;
apartment = 77;
if (countNights > 14) {
apartment = apartment * 0.9;
}
}
let priceApartment = (countNights * apartment).toFixed(2);
let priceStudio = (countNights * studio).toFixed(2);
console.log(`Apartment: ${priceApartment} lv.`);
console.log(`Studio: ${priceStudio} lv.`);
}
solve(`4`, `May`);
Благодаря!!!