Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GodzillaVSKong (input) {
- let budget = Number(input[0]); // бюдежет
- let extras = Number(input[1]); // брой статисти
- let clothesPerson = Number(input[2]); // цена за облекло на статист
- let totalPrice = 0;
- let decor = budget * 0.1; // декор = 10% от бюджета
- let clothesStaff = clothesPerson * extras; // общо пари за облелко на статистите
- if (extras > 150) { // ако статистите са повече от 150
- clothesStaff = clothesStaff * 0.9; // отстъпка 10% от цена на облеклото
- totalPrice = decor + clothesStaff; // общо необходими пари
- } else {
- totalPrice = decor + clothesStaff; // общо необходими пари
- }
- if (totalPrice > budget) { // проверяваме дали нужните ни пари са повече от бюджета
- let missingMoney = totalPrice - budget; // смятаме колко пари не стигат
- console.log(`Not enough money!`);
- console.log(`Wingard needs ${missingMoney.toFixed(2)} leva more.`);
- }
- else {
- let extraMoney = budget - totalPrice; // смятаме колко пари ще останат
- console.log(`Action!`);
- console.log(`Wingard starts filming with ${extraMoney.toFixed(2)} leva left.`);
- }
- }
- GodzillaVSKong(["15437.62","186","57.99"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement