-
-
Save Nothing-Works/e11dea75a4e78781a21919d6a6f88b00 to your computer and use it in GitHub Desktop.
random ST question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let arr = [ | |
| { | |
| name: 'user', | |
| age: 1 | |
| }, | |
| { | |
| name: 'teacher', | |
| age: 9 | |
| }, | |
| { | |
| name: 'user', | |
| age: 2 | |
| }, | |
| { | |
| name: 'teacher', | |
| age: 8 | |
| }, | |
| { | |
| name: 'accountant', | |
| age: 3 | |
| }, | |
| ] | |
| let result = [...new Set(arr.map(a => a.name))].map( key => [...arr.filter(c=>c.name === key)]); | |
| console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment