Advertisement
bebo231312312321

Untitled

Mar 4th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function companyUser(input){
  2. let users= {}
  3. input.forEach(line => {
  4.     [company, employe] = line.split(" -> ")
  5.     if(!users.hasOwnProperty(company)){
  6.         users[company] = new Set()
  7.     }
  8.     users[company].add(employe)  
  9. });
  10. let sorted = Array.from(Object.entries(users)).sort()
  11. .forEach(key=>{
  12.     console.log(key[0])
  13.     for(let el of key[1]){
  14.         console.log(`--`,el)
  15.     }
  16. })
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement