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

170
Vistas
How to iterate json consists of array elements

I am getting this object :

"contributionData": {
        "Contribution 1": [
            4,
            4
        ],
        "Contribution 2": [
            1,
            1
        ]
    }

I want this kind of table after iteration.

contribution1 |  4  |  4  |
contribution2 |  1  |  1  |

I've converted it to array :

        let result = [];

        for(let i in this.state.testData) {
            result.push([i, this.state.testData[i]]);
        }

console log after converting it to array

   <tr>
       <td>{this.state.result}</td>
   </tr>

I want to fill this data in table format I am working on React js, I want to do this in javascript.

Any help would be appreciated.

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

0

Try this one.

let result = []
let data = {
  "Contribution 1": [
            4,
            4
        ],
        "Contribution 2": [
            1,
            1
        ]
}
Object.keys(data).map((item) => {result.push([item].concat(data[item]))})
console.log(result);
...
{
    results.map(item, i)=> (
      <tr key={i}>
          {item.map(val, index) => (
            <td key={"row" + index}>{val}</td>
          )}
      </tr>
    )
}
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