title: Can't call a function defined in external JS file
body: <p>Wanted to try out using external JS file, but I can't seem to be able to call a function I defined there. Every time I try to call it, an error "Uncaught ReferenceError: calculate (function name) is not defined" is returned. I've been coding for only a week, so trying to figure out my error myself led me nowhere.</p>
  
  <p>Chunks of code:</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta charset= "utf-8"&gt;
      &lt;script type= "text/javascript" src= "nameOfFile.js"&gt;&lt;/script&gt;
  &lt;/head
  </code></pre>
  
  <p>Trying to call the function:</p>
  
  <pre><code>&lt;select type= "select" id = "currency" onchange= "calculate()"&gt;
                          &lt;option value= "RUB", selected&gt; RUB &lt;/option&gt;
                          &lt;option value= "USD"&gt; USD &lt;/option&gt;
                          &lt;option value= "EUR"&gt; EUR &lt;/option&gt;
                          &lt;option value= "GBP"&gt; GBP &lt;/option&gt;
  </code></pre>
  
  <p>The function in external file:</p>
  
  <pre><code>function calculate() {
   var currencyName = document.getElementById("currency");
   var currency = currencyName.value;
   var time = document.getElementById("timeInput");
   var sum = document.getElementById("sumInput");
   var amount = sum.value;
   var income; //pure percent revenue
   var earnings; //income + revenue
   var result = document.getElementById("results");
   var percentage;
  
  
   switch (currency) {
      case RUB:
          if (time&gt;= 3 &amp;&amp; time &lt;= 5) {
              percentage = 5;
          }
          else if (time &gt;= 6 &amp;&amp; time &lt;= 11){
              percentage = 6;
          }
          else if (time &gt;= 12 &amp;&amp; time &lt;= 24){
              percentage = 6,5;
          }
  
       break;
  
      case USD:
          if (time&gt;= 3 &amp;&amp; time &lt;= 5) {
              percentage = 0,1;
          }
          else if (time &gt;= 6 &amp;&amp; time &lt;= 11){
              percentage = 0,5;
          }
          else if (time &gt;= 12 &amp;&amp; time &lt;= 24){
              percentage = 1;
          }
      break;
  
      case EUR:
      case GBP:
          if (time&gt;= 3 &amp;&amp; time &lt;= 5) {
              percentage = 0,1;
          }
          else if (time &gt;= 6 &amp;&amp; time &lt;= 11){
              percentage = 0,25;
          }
          else if (time &gt;= 12 &amp;&amp; time &lt;= 24){
              percentage = 0,5;
          }
      break;
   }
  
   income = percentage / 100 * amount;
   earnings = amount + income;
  </code></pre>
  
  <p>}</p>
  
  <p>The page seems to recognize the existence of .js file, I can see it in "Sources" tab in Chrome, for example. Both files are in the same folder.</p>
  
  <p>EDIT: Problem solved, see my answer.</p>