title: How do I change variable in a function from another file?
body: <p>I have some code like this: </p>
  
  <pre><code>//app.js
  var r=require("./second.js");
  var a=1;
  r.second(a);
  console.log(a);
  </code></pre>
  
  <p>And my second.js looks like this:</p>
  
  <pre><code>//second.js
  module.exports.change=function(a){
      a=2;
  }
  </code></pre>
  
  <p>Currently console.log(a) only show 1, I did a bit of research saying I can't pass it as a variable because variable is passed as value. I thought about using global.a. However, it doesn't work too because a is stored as a module variable, not a global variable, and I don't want to set it as a global variable.</p>
  
  <p>How do I solve it?</p>