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

203
Vistas
How can I create a Table in JS with "for loops" filled with numbers 1 to 100

I created multiplication table using for loop

now I need to create the same table with numbers 1 to 100 like this one:[table][1]

how do I create this one [1]: https://i.stack.imgur.com/FAacu.png

document.write('<table border="3">');
for (var x = 1; x < 11; x++) {
  document.write("<tr>")
  for (let i = 1; i < 11; i++) {
    document.write("<td>" + x * i + "</td>")
  }
  document.write("</td>")
}
document.write("</table>")

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

0

You can start x from 0 (to 10) then the formula of the current cell's number is x * 10 + i so for [2,2] cell it would be 1 * 10 + 2

document.write('<table border="3">');
for (let x = 0; x < 10; x++) {
  document.write("<tr>")
  for (let i = 1; i <= 10; i++) {
    document.write("<td>" + (x * 10 + i) + "</td>")
  }
  document.write("</td>")
}
document.write("</table>")

about 4 years ago · Juan Pablo Isaza Denunciar

0

I have looked into your code and seems like logic inside your for loop is not correct.

I am posting a working code logic for this, I hope this is what you need.

document.write('<table border="3">');
for (var x = 1; x <= 100; x += 10) {
  document.write("<tr>");
  for (let i = x; i <= x + 9; i++) {
    document.write("<td>" + i + "</td>");
  }
  document.write("</td>");
}
document.write("</table>");

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