• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Mar 28th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. function solve(input) {
2.     let sum = Number(input.shift())
3.     let gender = input.shift()
4.     let age = Number(input.shift())
5.     let sport = input.shift()
6.     let price = 0;
7.
8.     if (gender == 'm') {
9.         switch (sport) {
10.             case 'Gym':
11.                 price = 42;
12.                 break;
13.             case 'Boxing':
14.                 price = 41;
15.                 break;
16.             case 'Yoga':
17.                 price = 45;
18.                 break;
19.             case 'Zumba':
20.                 price = 34;
21.                 break;
22.             case 'Dances':
23.                 price = 51;
24.                 break;
25.             case 'Pilates':
26.                 price = 39;
27.                 break;
28.         }
29.
30.         if (age <= 19) {
31.             price -= (price*0.2)
32.         }
33.
34.     } else if (gender == 'f') {
35.         switch (sport) {
36.             case 'Gym':
37.                 price = 35;
38.                 break;
39.             case 'Boxing':
40.                 price = 37;
41.                 break;
42.             case 'Yoga':
43.                 price = 42;
44.                 break;
45.             case 'Zumba':
46.                 price = 31;
47.                 break;
48.             case 'Dances':
49.                 price = 53;
50.                 break;
51.             case 'Pilates':
52.                 price = 37;
53.                 break;
54.         }
55.
56.         if (age <= 19) {
57.             price -= (price*0.2)
58.         }
59.     }
60.
61.
62.     if (sum >= price) {
63.         console.log(`You purchased a 1 month pass for \${sport}.`)
64.     } else {
65.         let money = price - sum
66.         console.log(`You don't have enough money! You need \$\${money.toFixed(2)} more.`)
67.     }
68. }
69.
70. solve([
71.     10,
72.     'm',
73.     50,
74.     'Pilates'
75. ])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top