Javascript - Function Not Changing Global Variable : <p>My Code (Javascript):</p>

<pre><code>var num = 0;
function change(){
    var num = 10;
}
        change();
        document.write(num);
</code></pre>

<p>The result should be <b>10</b> but it is showing 0. Why?<br>
If the code is wrong, what is the correct way to do this?</p>
