This file contains 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
// so, you have list of users like this | |
const users = [ | |
{ id: '1', name: 'hello' }, | |
{ id: '2', name: 'world' }, | |
{ id: '3', name: 'hello' }, | |
{ id: '1', name: 'hello' }, | |
{ id: '1', name: 'hello' }, | |
] | |
// as a result, we want to get list of users without duplicates, basing on id. | |
const res = [ | |
{ id: '1', name: 'hello' }, | |
{ id: '2', name: 'world' }, | |
{ id: '3', name: 'hello' } | |
] | |
// I suggest you, not to use forEach or for methods. |