Ура, новая тема академии, так что представляю на Ваш суд свою версию:
С Новым Годом, работяги!
let getPrice = function (hours, isUrgency) {
let hourlyRate = 1500;
if (isUrgency) {
hours /= 2;
hourlyRate *= 2.5;
}
if (hours > 150) {
hourlyRate -= 250;
}
return hours * hourlyRate;
}
let getProfitableProject = function(hours, netProfitIfUrgent) {
let urgentValue = getPrice(hours, true) - netProfitIfUrgent;
let notUrgentValue = getPrice(hours, false);
let urgency = 'срочный';
let expences = urgentValue;
if (urgentValue > notUrgentValue) {
urgency = 'обычный';
expences = notUrgentValue;
}
return `Выгодней ${urgency} проект. Потратишь на него ${expences}`;
}
Странно, что надо указать именно маржинальные расходы в срочном проекте, а не саму стоимость срочного проекта.