środa, 28 sierpnia 2019

Programming exercise #13 - get only unique items from array of objects

// 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.
view raw gistfile1.txt hosted with ❤ by GitHub

Brak komentarzy:

Prześlij komentarz