• Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Precios
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

99
Vistas
find and create a new array just with one sort of value and eliminate duplicates (if many)

I'm trying to find a method for sorting an array by uuid and eliminate the duplicate.

For exemple i have a array like this :

const x = [
{id: 1, uuid: xxxx-xxxx-xxxx-xxxx, content: 'string'},
{id: 2, uuid: xxxx-xxxx-xxxx-xxxx, content: 'string'},
{id: 3, uuid: xxxx-xxxx-xxxx-xxxx, content: 'string'},
{id: 4, uuid: xxxx-xxxx-xxxx-xxxx, content: 'string'},
{id: 5, uuid: xxxx-xxxx-xxxx-xxxx, content: 'string'},
{id: 6, uuid: xxxx-xxxx-xxxx-xxxx, content: 'string'},
{id: 7, uuid: yyyy-yyyy-yyyy-yyyy, content: 'string'},
{id: 8, uuid: zzzz-zzzz-zzzz-zzzz, content: 'string'}
]

And i'm trying to find a simple way for making this in result :

const x = [xxxx-xxxx-xxxx-xxxx, yyyy-yyyy-yyyy-yyyy, zzzz-zzzz-zzzz-zzzz]

I know it's maybe basic but my brain is off i guest ...

Thanks !

9 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this, but i used a string type for uuid:

[...new Set(x.map(e => e.uuid))].sort()
9 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.