title: var is undefined if using var keyword node
body: <p>Building a small MVC. When I'm receiving results back from my model, the variable that I'm using to send to my view is undefined if I use the "var" keyword. If I don't use the keyword the object comes through just fine. What is happening?</p>
  
  <p>Controller</p>
  
  <pre><code>const homeModel = require('../models/homeModel.js');
  
  exports.index = function(req, res){
  
  homeModel.getAllStores(function (err, res) {
      if (err) return err;
      stores = res; // Works
      var stores = res // Undefined
  })
  
  console.log(stores);
  res.render('home', {stores: stores});
  }
  </code></pre>
  
  <p>Here is the Model</p>
  
  <pre><code>const db = require('../db.js');
  
  exports.getAllStores = function(done) {
  
  db.query('select * from stores;', (err, rows) =&gt; {
      if (err) return done(err);
  
      let resultJson = JSON.stringify(rows);
      resultJson = JSON.parse(resultJson);
  
      return done(null, resultJson);
  
  })
  }
  </code></pre>