title: How to use multiple JS files and make them interact with each other
body: <p>I am new to Java script.  I couldn't figure out how to make multiple JS files to be able to call each other's functions or use each other's classes.</p>
  <p>Here is the structure of my small project:</p>
  <ul>
  <li>./index.hml</li>
  <li>./css/style.css</li>
  <li>./script/library.js</li>
  <li>./script/main.js</li>
  <li>./script/demo.js</li>
  </ul>
  <p>All my logic is in library.js. It has a class called &quot;Transaction&quot; and another one called &quot;Settler&quot;. All my business logic is in this file.</p>
  <p>The demo.js is supposed to create some random data and then create Transaction objects in an array, and then send to Settler object.</p>
  <p>I cannot make the demo.js to see the library.js. Can anyone help.</p>
  <p>Here is what I want to do in demo.js:</p>
  <pre><code>demo(){
    1. for-loop:  create one random &quot;Transaction&quot; and add it to a map
    2. create a Settler object and send my Transaction-map object to the object as a contructor argument
  
  }
  </code></pre>
  <p>main.js is for the index.html. So this one is supposed to use the demo.js only. The &quot;main.js&quot; has the dom manipulation. So &quot;main.js&quot; would use &quot;demo.js&quot; to get some randomized data and manipulate it on the index.html.</p>
  <p>I tried my luck with &quot;require&quot; etc, but I couldn't make it work..</p>
  <p>How can I have a separate js file and use the class definitions and methods in that file from my own js code?</p>
  <p>Thanks</p>
  <p>Note: I use Visual Studio Code and run my code initially on nodejs.</p>