Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fitnessCard(input) {
- let cash = Number(input.shift());
- let sex = input.shift();
- let age = Number(input.shift());
- let sport = input.shift();
- let sum = 0;
- if (sex === "m") {
- switch (sport) {
- case "Gym":
- sum = 42;
- break;
- case "Boxing":
- sum = 41;
- break;
- case "Yoga":
- sum = 45;
- break;
- case "Zumba":
- sum = 34;
- break;
- case "Dances":
- sum = 51;
- break;
- case "Pilates":
- sum = 39;
- break;
- }
- } else if (sex === "f") {
- switch (sport) {
- case "Gym":
- sum = 35;
- break;
- case "Boxing":
- sum = 37;
- break;
- case "Yoga":
- sum = 42;
- break;
- case "Zumba":
- sum = 31;
- break;
- case "Dances":
- sum = 53;
- break;
- case "Pilates":
- sum = 37;
- break;
- }
- }
- if (age <= 19) {
- sum *= 0.8;
- }
- if (sum <= cash) {
- console.log(`You purchased a 1 month pass for ${sport}.`);
- } else {
- console.log(`You don't have enough money! You need $${(sum - cash).toFixed(2)} more.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement