I need to write a script that displays the first 20 numbers in the fibonacci sequence in a web page. It also has to display these numbers in a table that is one column wide and 20 rows long. My javascript to display the numbers works, but I can't figure out how to get them to display in a table.
This is what I have so far:
<script type="text/javascript">
<!--
var var1 = 0;
var var2 = 1;
var var3;
var num = 20;
document.write("<tr><td>"+var1+"</td></tr>");
document.write("<tr><td>"+var2+"</td></tr>");
for(var i=3; i <= num;i++)
{
var3 = var1 + var2;
var1 = var2;
var2 = var3;
document.write("<tr><td>"+var3+"</td></tr>");
}
// -->
</script>