Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function schoolCamp(data) {
- var season = data[0];
- var groupType = data[1];
- var countStud = Number(data[2]);
- var countNights = Number(data[3]);
- var totalPrice = 0;
- var pricesMap = {
- "boys": {
- "Spring": 7.20,
- "Summer": 15,
- "Winter": 9.60
- },
- "girls": {
- "Spring": 7.20,
- "Summer": 15,
- "Winter": 9.60
- },
- "mixed": {
- "Spring": 9.50,
- "Summer": 20,
- "Winter": 10
- }
- };
- var activMap = {
- "boys": {
- "Spring": "Tennis",
- "Summer": 'Football',
- "Winter": 'Judo'
- },
- "girls": {
- "Spring": 'Athletics',
- "Summer": 'Volleyball',
- "Winter": "Gymnastics"
- },
- "mixed": {
- "Spring": 'Cycling',
- "Summer": 'Swimming',
- "Winter": 'Ski'
- }
- };
- totalPrice = countNights * countStud * (pricesMap[groupType][season]);
- if (countStud >= 50) {
- totalPrice = totalPrice * 0.50;
- } else if (countStud >= 20 && countStud < 50) {
- totalPrice = totalPrice * 0.85;
- } else if (countStud >= 10 && countStud < 20) {
- totalPrice = totalPrice * 0.95;
- } else {
- totalPrice = totalPrice;
- }
- console.log(`${activMap[groupType][season]} ${totalPrice.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement