Cannot retrieve global variable's value inside function?
<p>I keep getting "undefined" as result from returning the variable inside a function.</p>

<p>This is the code:</p>

<pre><code>var nloads = 1;
function something(loc) {
    console.log(nloads); // returns 1
}
function changeSection(loc) {
    console.log(nloads); // Returns undefined
    nloads = nloads + 1;
    temp = nloads;
}
</code></pre>

<p>What's wrong with it?/What may be causing the problem?</p>
