Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function godzillaVsKong(input) {
- let budget = Number(input[0]),
- statists = Number(input[1]),
- dresses = Number(input[2]),
- decors = budget / 10;
- if (statists > 150) {
- dresses *= 0.9;
- }
- let price = decors + statists * dresses;
- if (budget >= price) {
- console.log(`Action!\nWingard starts filming with ${budget - price.toFixed(2)} leva left.`);
- } else {
- console.log(`Not enough money!\nWingard needs ${Math.abs(price - budget).toFixed(2)} leva more.`);
- }
- }
- Решение с тернарен оператор:
- function godzillaVsKong(input) {
- let budget = Number(input[0]),
- statists = Number(input[1]),
- dresses = Number(input[2]),
- decors = budget / 10;
- budget -= decors + statists * (statists > 150 ? 0.9 : 1) * dresses;
- console.log(budget >= 0 ? `Action!\nWingard starts filming with ${budget.toFixed(2)} leva left.`
- : `Not enough money!\nWingard needs ${Math.abs(budget).toFixed(2)} leva more.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement