title: Cannot send variable name from one node module to another to use it as a room-name for chat application using socket.io
body: <p>I am able to get the room name from user but as I use <code>module.exports</code> in another file to retrieve it shows undefined . This might be because it is asynchronous. </p>
  
  <p>//roomcheck.js</p>
  
  <pre><code>var nsp = io.of("/gameroom");
  nsp.on('connection', (socket) =&gt; {
  socket.on('check', (data) =&gt; {
      if (rm.includes(data)) {
          roomname = data;
          console.log(roomname);
          console.log("Room exist!!!");
          socket.emit('success', 'room already made');
  });
  
  module.exports=roomname;
  </code></pre>
  
  <p>//userpage.js</p>
  
  <pre><code>var r=require('roomcheck.js');
  console.log(r.roomname);
  </code></pre>
  
  <p><strong>Expected</strong> - roomname entered by user.</p>
  
  <p><strong>My output</strong> - undefined</p>