# Solve the Problem

a guest
Jul 3rd, 2019
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. class Vacation {
2.     constructor(organizer, destination, budget) {
3.         this.organizer = organizer;
4.         this.destination = destination;
5.         this.budget = budget;
6.         this.kids = {};
7.     }
8.
10.         if (this.budget > budget) {
11.             return `\${name}'s money is not enough to go on vacation to \${this.destination}.`;
12.        }
13.
16.        }
17.
18.        for (let students of this.kids[grade]) {
19.            let kidName = students.split("-")[0]
20.            if (kidName === name) {
21.                return `\${name} is already in the list for this \${this.destination} vacation.`;
22.            }
23.        }
24.
25.        let pattern = `\${name}-\${budget}`;
28.    }
29.
33.         }
34.
35.         let index = -1;
36.         for (let students of this.kids[grade]) {
37.             let kidName = students.split("-")[0];
38.             index++;
39.             if (kidName === name) {
42.             }
43.         }
44.
46.    }
47.
48.    toString() {
49.        if (this.numberOfChildren === 0) {
50.            return `No children are enrolled for the trip and the organization of \${this.organizer} falls out...`;
51.        }
52.
53.        let output = `\${this.organizer} will take \${numberOfChildren} children on trip to \${this.destination}\n`;
54.        this.kids = this.kids.sort((a, b) => {
55.            return Number(Object.keys(a)) - Number(Object.keys(b));
56.        });
57.
58.        for (let key in this.kids) {
60.            let number = 1;
61.            for (let student of this.kids[key]) {
62.                output += `\${number++}. \${student}\n`
63.            }
64.        }
65.
66.        return output;
67.    }
68.
69.    get numberOfChildren() {
70.        let counter = 0;
71.        for (let grade in this.kids) {
73.        }
74.
75.        return counter;
76.    }
77. }
78.
79. // let vacation = new Vacation('Miss Elizabeth', 'Dubai', 2000);
80. // vacation.registerChild('Gosho', 5, 3000);
81. // vacation.registerChild('Lilly', 6, 1500);
82. // vacation.registerChild('Pesho', 7, 4000);
83. // vacation.registerChild('Tanya', 5, 5000);
84. // vacation.registerChild('Mitko', 10, 5500)
85. // console.log(vacation.toString());