let getPrice = function (timeInHours, isUrgent) {
let rate = 1500;
if(isUrgent) {
timeInHours /= 2;
let urgentHours = timeInHours / 2;
if(urgentHours <= 150) {
rate *= 2.5;
}else{
rate -= 250;
}
};
if(timeInHours > 150) {
rate -= 250;
};
return timeInHours * rate;
}
23/23 Сколько стоит ваш фронтенд? ✓ Done.
let getPrice = function (timeInHours, isUrgent) {
let rate = 1500;
if(isUrgent) {
timeInHours /= 2;
rate *= 2.5;
}
if(timeInHours > 150) {
rate -= 250;
};
return timeInHours * rate;
}
Более простой вариант чего-то сразу не приняло… нужно было искать ошибку… Теперь работает и простой.
1 Симпатия
let getPrice = function (time, quick){
let priceInHour = 1500;
if(quick){
time = time / 2;
priceInHour = priceInHour * 2.5;
}
if(time > 150){
priceInHour = priceInHour - 250;
}
return time * priceInHour;
getPrice = 1500 * time;
};