Advertisement
Guest User

07

a guest
Oct 1st, 2016
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(n) {
  2. let html = '<table border="1">\n' + '<tr><th>x</th>';
  3.     for (let firstRow = 1; firstRow <=n; firstRow++) {
  4.         html += `<th>${firstRow}</th>`
  5.     }
  6.  
  7.     html += '</tr>\n';
  8.     for (let row = 1; row <=n; row++)
  9.     {
  10.         html += '<tr>'
  11.         html += `<th>${row}</th>`
  12.     for (let col = row; col <= (n*row); col+=row) {
  13.         html += `<td>${col}</td>`;
  14.         }
  15.         html += '</tr>\n'
  16.     }
  17. html += '</table>'
  18. return html;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement