Advertisement
Guest User

07.MultiplicationTable

a guest
Oct 1st, 2016
890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. function printTable([num]) {
  2. num = Number(num);
  3. let html = `<table border="1">\n`;
  4. for (let i = 0; i <= num; i++) {
  5. let countNum = i;
  6. html += ` <tr>`;
  7. for (let j = 0; j <= num; j++) {
  8. if (i == 0) {
  9. if (j == 0) html += `<th>x</th>`;
  10. else html += `<th>${j}</th>`;
  11. }
  12. else {
  13. if(j == 0)html += `<th>${i}</th>`;
  14. else {
  15. html += `<td>${countNum}</td>`;
  16. countNum += i;
  17. }
  18. }
  19. }
  20. html += `</tr>\n`;
  21. }
  22. html += `</table>`;
  23. return html
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement