Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function companyEmployees(input) {
- let companies = {};
- for (let line of input) {
- let [company, employee] = line.split(" -> ");
- if (!companies.hasOwnProperty(company)) {
- companies[company] = new Set();
- }
- companies[company].add(employee);
- }
- let sortedCompanies = Object.keys(companies).sort();
- for (let company of sortedCompanies) {
- console.log(company);
- for (let employee of companies[company]) {
- console.log(`-- ${employee}`);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment