JavaScript Beginner Question (Loops)
<p>Today is my first day in JavaScript. The book (JavaScript Definitive Guide) has an excersice printing all the factorials.</p>

<p>This is what I did:</p>

<pre><code>&lt;html&gt;
&lt;b&gt;&lt;head&gt; Factorial - JavaScript - Ex1&lt;/head&gt;&lt;/b&gt;
&lt;body&gt;
        &lt;h2&gt; Factorials List &lt;/h2&gt;
&lt;script&gt;

        var fact = 1; 
        var num = 1;
        for(num &lt;= 10; num++)
            {
                fact=fact*num;
                document.write(num + "! = " + fact + "&lt;br&gt;");

            }
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>There is a problem which I don't exactly know. I checked the book and the way that writer solved it was by initializing the variable num inside the loop FOR. I did that and it worked.
But what is the difference between that and mine?</p>

<p>Enlighten me Experts :)</p>
