Advertisement
DraconiusNX

Untitled

Sep 30th, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function GodzillaVSKong (input) {
  2.  
  3.     let budget = Number(input[0]); // бюдежет
  4.     let extras = Number(input[1]); // брой статисти
  5.     let clothesPerson = Number(input[2]); // цена за облекло на статист
  6.     let totalPrice = 0;
  7.     let decor = budget * 0.1; // декор = 10% от бюджета
  8.     let clothesStaff = clothesPerson * extras; // общо пари за облелко на статистите
  9.  
  10.     if (extras > 150) { // ако статистите са повече от 150
  11.         clothesStaff = clothesStaff  * 0.9; // отстъпка 10% от цена на облеклото
  12.         totalPrice = decor + clothesStaff; // общо необходими пари
  13.     } else {
  14.         totalPrice = decor + clothesStaff; // общо необходими пари
  15.         }
  16.  
  17.     if (totalPrice > budget) { // проверяваме дали нужните ни пари са повече от бюджета
  18.         let missingMoney = totalPrice - budget; // смятаме колко пари не стигат
  19.         console.log(`Not enough money!`);
  20.         console.log(`Wingard needs ${missingMoney.toFixed(2)} leva more.`);
  21.     }
  22.     else {
  23.         let extraMoney = budget - totalPrice; // смятаме колко пари ще останат
  24.         console.log(`Action!`);
  25.         console.log(`Wingard starts filming with ${extraMoney.toFixed(2)} leva left.`);
  26.     }
  27.  
  28. }
  29.    
  30. GodzillaVSKong(["15437.62","186","57.99"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement