PB Javascript - Fishing Boat - Problem
Привет!
Имам проблем със задачката 'рибарска лодка'. Всичко изглежда нормално, но джъдж ми дава 60/100.
Ето го моя код:
function fishBoat(input) {
let budget = Number(input[0]);
let season = input[1];
let fcount = Number(input[2]);
let price = 0;
switch(season) {
case 'Spring':
price = 3000;
if(fcount <= 6) {
price *= 0.90;
} else if(fcount >= 7 && fcount <= 11) {
price *= 0.85;
} else if(fcount >= 12) {
price *= 0.75;
}
break;
case 'Summer':
price = 4200;
if(fcount <= 6) {
price *= 0.90;
} else if(fcount >= 7 && fcount <= 11) {
price *= 0.85;
} else if(fcount >= 12) {
price *= 0.75;
}
break;
case 'Autumn':
price = 4200;
if(fcount <= 6) {
price *= 0.90;
} else if(fcount >= 7 && fcount <= 11) {
price *= 0.85;
} else if(fcount >= 12) {
price *= 0.75;
}
break;
case 'Winter':
price = 2600;
if(fcount <= 6) {
price *= 0.90;
} else if(fcount >= 7 && fcount <= 11) {
price *= 0.85;
} else if(fcount >= 12) {
price *= 0.75;
}
break;
}
if(fcount % 2 == 0 && season != 'Autumn') {
let price = price * 0.95;
}
let diff = Math.abs(budget - price);
if(budget >= price) {
console.log(`Yes! You have ${diff.toFixed(2)} leva left.`);
} else {
console.log(`Not enough money! You need ${diff.toFixed(2)} leva.`);
}
}