Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

248
Vistas
How to show the data of each month in one row

Hi I have a list of data stored in an array ,the |arraycontains the list ofobjects`.Each object has certain properties like name,created-at etc. Now I want to show all the users that are created in a particular month ,show in one row,like if the two users are created in the month of November I want to show these two users in one row.having the heading month name and year.

let users[{name: user1, created-at: November},{},{}];

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I created an array of unique createdAt values from an users array. Then I mapped this table and added to it every user that has the same creation date

function App() {
  let users = [
    {name: 'user1', createdAt: 'November'},
    {name: 'user5', createdAt: 'November'},
    {name: 'user2', createdAt: 'April'}];
  let rows = [...new Set(users.map(item => item.createdAt))];
  return (
    <div className="App">
      {rows.map(i=><div>
        <h1>{i}</h1>
        <ol>{users.map(j => i === j.createdAt ? <li>{j.name}</li>: null)}</ol>
      </div>)}
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You may want to create some form of 'groupBy' function in order to achieve this. Have a look at this example.

const users = [{
    firstName: "Garnet",
    createdAt: "January"
  },
  {
    firstName: "Pearl",
    createdAt: "February"
  },
  {
    firstName: "Amethyst",
    createdAt: "January"
  },
  {
    firstName: "Steven",
    createdAt: "March"
  }
]

function groupBy(array, key) {
  return array.reduce((acc, obj) => {
    const property = obj[key]
    acc[property] = acc[property] || []
    acc[property].push(obj)
    return acc
  }, {})
}

console.log(groupBy(users, 'createdAt'))

about 4 years 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 vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda