Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda