popovIliya

March-2022-Conditional Statements - Exercise -Godzilla vs. Kong

Mar 13th, 2022
1,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function funds(input){
  2.     let budget = Number(input[0]);
  3.     let walkerOn = parseInt(input[1]);
  4.     let priceClothing = Number(input[2]);
  5.     let discount = 0.00, total = 0.00;
  6.     let decor = ((budget * 10) / 100);
  7.     let clothingSum = walkerOn * priceClothing;
  8.     if(walkerOn > 150){
  9.         discount = clothingSum * 0.10;
  10.     }
  11.     total = ((decor + clothingSum) - discount);
  12.     let payment = Math.abs((budget - total));
  13.     if (budget >= total){
  14.         console.log('Action!');
  15.         console.log(`Wingard starts filming with ${(payment).toFixed(2)} leva left.`);    
  16.     }
  17.     else{
  18.         console.log('Not enough money!');
  19.         console.log(`Wingard needs ${(payment).toFixed(2)} leva more.`);
  20.     }
  21.    
  22. }
Advertisement
Add Comment
Please, Sign In to add comment