Write a program that creates a text file that contains a power of two table in HTML format. The file could be called "twoPowerTable.html". When it is viewed with a browser you will see something like:

Power of 2 Value
0 1
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512
10 1024

The file should start with something like:

<title>Powers of Two</title>
<table border cellpadding=5>
<tr><th>Power of 2</th><th>Value</th></tr>

And end with:


Each line of the table looks like:


I don't know why it can't show the table but i am doing the Exercises in this website: http://chortle.ccsu.edu/java5/Notes/chap83/progExercises83.html

I guess this is a homework assigment? Well I will tell you how you can do it, but I will not write the code for you.

1. Create the document with the table (it needs to have a id attribute)
2. Write a function in JavaScript that calculates the powers of 2 and dynamically add the rows to the table.

You can learn about adding rows to a table here: http://www.w3schools.com/js/tryit.asp?filename=try_dom_table_insertrow


yep! it's homework assignment! Anyway thx a lot though


<script type="text/javascript">
function insRow()
var temp=1;
for (i=1;i<=11;i++)
	var x=document.getElementById('myTable').insertRow(0);
	var y=x.insertCell(0);
	var z=x.insertCell(1);
	if (i==1) {

<table id="myTable" border="1">
<tr align="center">
<td colspan="2">End of the Table</td>
<br />
<input type="button" onclick="insRow()" value="Insert row">

I dont know how to insert after a row