title: External Javascript calling functions from another external javascript file
body: <p>So, I've looked at other questions like this and they haven't really answered the questions.</p>
  
  <p>In short: I've worked with HTML, Java, VB, and whatever language MIRC uses(it's been a little under 10 years).</p>
  
  <p>I'm new to javascript, but because of my other computer language know-how's... I know that using Java, I can create class's and class-like functions.</p>
  
  <p>But, with html/javascript, I'm not sure how to call a function from one external .js file to another.</p>
  
  <p>Let's say: I want to make a player class that I can call functions from anytime and use it in the 'main' .js file that uses those functions from that class inside another function. For example.</p>
  
  <p>If I had</p>
  
  <pre><code>function isDead() {
  if (health &lt; 10 || energy &lt; 10)
  {
  return dead = 'true';
      }
      else { return dead; }
  }
  </code></pre>
  
  <p>in Player .js file, and in the main one, I had.</p>
  
  <pre><code>function fight() {
  if (isDead() == 'true')
  {
      energy -= 10;
       health -= 10;
      Swords();
  }
  
  
  document.getElementById("energy").innerHTML = energy;
  document.getElementById("health").innerHTML = health;
  document.getElementById("sword").innerHTML=sword;
  
  }
  </code></pre>
  
  <p>In the item.js I had</p>
  
  <pre><code>var swordDamage = 0;
  
  function Swords(){
  if (swordDamage &lt; 3)
  swordDamage +=1;
  else
  return sword -=1;
  }
  </code></pre>
  
  <p>(Mind you this actually worked (I haven't tested the swords() yet as I just made it for this question.)</p>
  
  <p>Is there any particular way I need to call upon the functions from other .js files into the main.js file.</p>
  
  <p>example: 
      main.function();</p>
  
  <p>or am I better off saving them as an html document and writing nothing but script to get around this?</p>
  
  <p>Thanks for answering!</p>