Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fishingBoat0(input) {
- let [budget, season, fishermenCount, price, diff] = [+input[0], input[1], +input[2], 0, 0]
- switch (season) {
- case 'Spring':
- price = 3000
- break
- case 'Summer':
- case 'Autumn':
- price = 4200
- break
- case 'Winter':
- price = 2600
- }
- switch (true) {
- case fishermenCount <= 6:
- price = price - price * 0.1
- break
- case fishermenCount >= 7 && fishermenCount <= 11:
- price = price - price * 0.15
- break
- case fishermenCount >= 12:
- price = price - price * 0.25
- }
- switch (true) {
- case (fishermenCount % 2 == 0 && season != 'Autumn'):
- price = price - price * 0.05
- }
- diff = (Math.abs(budget - price)).toFixed(2)
- switch (true) {
- case (budget >= price):
- result = `Yes! You have ${diff} leva left.`
- break
- default:
- result = `Not enough money! You need ${diff} leva.`
- }
- console.log(result)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement