Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!