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

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

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

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 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