Having trouble getting the highest to show
<p>I need the highest value to display through a <code>for in</code> loop.
I got the three departments to display,but just after the <code>for in</code> loop It does not want to take in and give me the highest value. </p>

<p>So far the code loops successfully and gives me the required result. It should just <code>console.log</code> me the Outdoor as the department that's most profitable.</p>

<p>This is homework of mine,just too clarify cause I am not looking for an answer just clarification on how to do it. Simple and thorough. </p>

<pre><code>var salesData = [
  {department : 'hardware', sales : 4500, day : 'Monday'},
  {department : 'outdoor', sales : 1500, day : 'Monday'},
  {department : 'carpentry', sales : 5500, day : 'Monday'},
  {department : 'hardware', sales : 7500, day : 'Tuesday'},
  {department : 'outdoor', sales : 2505, day : 'Tuesday'},
  {department : 'carpentry', sales : 1540, day : 'Tuesday'},
  {department : 'hardware', sales : 1500, day : 'Wednesday'},
  {department : 'outdoor', sales : 8507, day : 'Wednesday'},
  {department : 'carpentry', sales : 8009, day : 'Wednesday'},
  {department : 'hardware', sales : 12000, day : 'Thursday'},
  {department : 'outdoor', sales : 18007, day : 'Thursday'},
  {department : 'carpentry', sales : 6109, day : 'Thursday'},
  {department : 'hardware', sales : 7005, day : 'Friday'},
  {department : 'outdoor', sales : 12006, day : 'Friday'},
  {department : 'carpentry', sales : 16109, day : 'Friday'},
];

function mostProfitableDepartment(salesList) {
  //group by department`
  var salesForEachDepartment = {};
  var high = 0;

  //loop through all the sales
  for (var i = 0; i &lt; salesList.length; i++) {
    //salesForEachDepartment += salesList[i];

    var deptDailySale = salesList[i];

    //check if the current department is in the salesForEachDepartment map
    if (salesForEachDepartment[deptDailySale.department] === undefined) {
      salesForEachDepartment[deptDailySale.department] = 0;
    }

    salesForEachDepartment[deptDailySale.department] += deptDailySale.sales;
    //deptDailySale.department
    //if ()
  }
  console.log(salesForEachDepartment);
}

mostProfitableDepartment(salesData);

for (var highestDepSale in salesForEachDepartment[deptDailySale.sales]) {
  if (salesForEachDepartment[highestDepSale.sales] &gt; highestDepSale) {
    highestDepSale = salesForEachDepartment[highestDepSale.sales];
  }
  console.log(highestDepSale);
}
</code></pre>