'use strict';

const vendorController = {};
const $vendorSort = $('#vendor-sort');

vendorController.render = function() {
  vendorController.fetchExp();
};

vendorController.fetchExp = function() {
  superagent
    .get('/lunch/vendors')
    .set('authorization', localStorage.getItem('token'))
    .end((err, res) => {
      if (err) throw err;
      let aggVendors = [].concat.apply([], res.body);
      aggVendors.sort(function(a, b){
        return b.worthIt - a.worthIt;
      });
      vendorView.populateHandlebars(aggVendors);
    });
};

$vendorSort.on('click', function() {
  page('/vendors');
});

@@ -480,16 +480,236 @@
     %7D);%0A
+      aggVendors.forEach(ven =%3E %7B%0A        ven.howFast = ven.howFast.toFixed(1);%0A        ven.cost = ven.cost.toFixed(1);%0A        ven.worthIt = ven.worthIt.toFixed(1);%0A      %7D);%0A      // Math.floor(aggVendors%5B1%5D.howFast);%0A
       ve

truncated aggregated ratings to 1 decimal point