Advertisement
bebo231312312321

Untitled

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