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

322
Vistas
How to loop through array of array of objects and put the data into table in node js

I have data like this:

Data =
            "Time": "06:04:01",
             location: canada,
            "user": [
                {
                    "name": "Drake",
                    "email": "drake@gmail.com",
                    "age": "16",
                },
                {
                    "name": "jack",
                    "email": "jack@gmail.com",
                    "age": "28",
                },
                {
                    "name": "peter",
                    "email": "sams@gmail.com",
                    "age": "20",
                },
    ]

I want to print them with console

I want to loop throught the data and print the data in a a table like this . in Node jS

I want to generate file with fs(file System library) and generate html file here... with table tags:

    str ="<table>
    <th>name</th>
    <th>email</th>
    <th>age</th>
    <td>";
        for(let i = 0; i < Data.user.length; i++){
          str+= JSON.stringify(Data.user[i].name);
        }
    str+= "</td><td>"
        for(let i = 0; i < Data.user.length; i++){
          str+= JSON.stringify(Data.user[i].email);
        }
    str+= "</td><td>"
        for(let i = 0; i < Data.user.length; i++){
          str+= JSON.stringify(Data.user[i].age);
        }
 str+= "</td><td></table>"
return str

I am geting data like : this

The table and everthing is okay there is something wrong with the looping or displaying. Please help me how can I print them like this. Thank you

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

0

Please find the below solution:

str ="<table>
    <th>name</th>
    <th>email</th>
    <th>age</th>";
for(let i = 0; i < Data.user.length; i++){
          str+= "<tr><td>"+JSON.stringify(Data.user[i].name)+"</td><td>"+JSON.stringify(Data.user[i].email)+"</td><td>"+JSON.stringify(Data.user[i].age)+"</td></tr>";
        }
    str+= "</table>"
return str
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