title: js - 2 variables assigned but only 1 working
body: <p>I have 2 variables. One is assigned inside a <code>.then</code> and the other assigned in a function. Later on only 1 is defined.</p>
  
  <p>Code excerpt...</p>
  
  <pre><code>let user;
  let station;
  const app = express();
  
  app.post("/api/user", (req, res) =&gt; {
      user = req.body.user; // Breakpoint added here to confirm user set
  }
  
  // Uses serialport module. Called when data received on serial port
  function serialPortListener(data) {
      getStation(data) // Retrieves record from database
      .then(s =&gt; {
          station = s; // Breakpoint added here to confirm station set
      ...
  }
  </code></pre>
  
  <p>I set breakpoints on both methods to confirm the variables are set. When I try to access them, later on, only <code>user</code> is defined. I'm assuming it's something to do with the context in which <code>station</code> is set?</p>
  
  <p><code>station</code> is not assigned anywhere else.</p>