title: Uncaught ReferenceError: {var} is not defined. Files are created separately
body: <p>Why am I getting <code>Uncaught ReferenceError: i is not defined</code> in my javascript file?</p>
  
  <p>So here's how I did it.</p>
  
  <p>app.js</p>
  
  <pre><code>$(function() {
    var i = 1;
  });
  </code></pre>
  
  <p>some.js</p>
  
  <pre><code>$(function() {
    alert(i);
  });
  </code></pre>
  
  <p>and here's how I sequence my files.</p>
  
  <pre><code>// included jquery here
  &lt;script src="/app.js" type="javascript/text"&gt;&lt;/script&gt;
  &lt;script src="/some.js" type="javascript/text"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>How can I execute or access variables from <code>app.js</code> or to other javascript files? I thought they should be listed in sequence. Where did I go wrong? Any help would be much appreciated. Thanks</p>