title: How do we return function using module.exports in nodeJS?
body: <p>How do we return function using module.exports in nodeJS?</p>
  
  <p><strong>file_1 book.js</strong>  </p>
  
  <pre><code>  module.exports = function() {
      var points = 0;
      return {
          rate: function(value) {
              points = value;
          },
          get: function() {
              return points;
          }
      }
  }
  </code></pre>
  
  <p>book.js is root file. We create two different instances but can not get the methods of root to script.js file.</p>
  
  <p><strong>file_2 main.js</strong>  </p>
  
  <pre><code>  var bA = require('./book.js');
    var bB = require('./book.js');
    bB.rate(10);
    bB.get();
  </code></pre>
  
  <p><strong>Output => <code>can not find rate and get method.</code></strong></p>