Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function main(lines) {
- let n=Number(lines[0]);
- console.log("<table border='1'>");
- let firstRow="<tr><th>x</th>";
- for (let i = 1; i <= n; i++) {
- firstRow+="<th>"+i+"</th>";
- }
- firstRow+="</tr>";
- console.log(firstRow);
- for (let i = 1; i <= n; i++) {
- let nextRow="<tr><th>"+i+"</th>";
- for (let k = 1; k <= n; k++) {
- nextRow+="<td>"+i*k+"</td>";
- }
- nextRow+="</tr>";
- console.log(nextRow);
- }
- console.log("</table>");
- }
- // main(['5']);
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <script src="test.js"></script>
- </head>
- <body>
- <script>
- document.body.innerHTML=main(['5']);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement