Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function godzillaVsKong(input) {
- let budget = Number(input[0]) * 0.9;
- let statist = Number(input[1]);
- let dress = Number(input[2]);
- if (statist > 150) {
- dress *= 0.9;
- }
- budget -= statist * dress;
- if (budget >= 0) {
- console.log(`Action!\nWingard starts filming with ${budget.toFixed(2)} leva left.`);
- } else {
- console.log(`Not enough money!\nWingard needs ${Math.abs(budget).toFixed(2)} leva more.`);
- }
- }
- Решение с тернарен оператор:
- function godzillaVsKong(input) {
- let budget = Number(input[0]) * 0.9;
- let statist = Number(input[1]);
- let dress = Number(input[2]);
- budget -= statist * (dress *= statist > 150 ? 0.9 : 1);
- 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