JavaScript Tutorial - 2 - one possible answer to Task 5
<html> <head> <title>Table of Squares and Cubes</title> </head> <body> <script> document.write("<table border=2 cellpadding=5>") document.write("<tr><th>number</th><th>square</th>") document.write("<th>cube</th></tr>") for (var n=1; n<101; n++) { document.write("<tr align=right><td>") document.write(n) document.write("</td><td>") document.write(n*n) document.write("</td><td>") document.write(n*n*n) document.write("</td></tr>") } document.write("</table>") </script> </body> </html>
numbersquarecube
111
248
3927
...
100100001000000
HOME Table of Contents