title: Find average of computed values with Angular
body: <p>So I'm trying to get the difference between two times off of each date in percentage (got that down) and then add all the percentages up and get the average but I couldn't figure out how to. The data is pulled from JSON. Any ideas? Help is much appreciated.</p>
  
  <p>This is the html:</p>
  
  <pre><code>&lt;div ng-controller="MainController as main"&gt;
  &lt;section class="view"&gt;
      &lt;h1&gt;Stuff&lt;/h1&gt;
          &lt;ul class="stuff"&gt;
              &lt;li ng-repeat="item in main.logs"&gt;
              &lt;p&gt;{{$index + 1}}&lt;/p&gt;
                  &lt;p&gt;{{ item.date }}&lt;/p&gt;
                  &lt;p&gt;{{ main.logs.calc(item.start, item.loggedIn) }} %&lt;/p&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
  &lt;/section&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>app.js file</p>
  
  <pre><code>angular.module('myApp', [
      'MainController'
  ]);
  </code></pre>
  
  <p>controller, what I have so far:</p>
  
  <pre><code>angular.module('myApp', [])
   .controller('MainController', ['$http', function($http){
  
      var checklog = this;
  
      checklog.logs = [];
  
      $http.get('./login.json').success(function(data){
          checklog.logs = data;
  
          checklog.logs.calc = function(d1, d2) {
              checklog.logs.percent = [];
  
              var d1 = new Date(d1).getTime();
              var d2 = new Date(d2).getTime();
              var diff = ( ((d2 - d1) / 60000) / 60 ) * 100 ;
  
              checklog.logs.percent = 100 - Math.floor(diff);
  
              return checklog.logs.percent;
          }
      });
  }]);
  </code></pre>
  
  <p>JSON is something like this:</p>
  
  <pre><code>[{  
      "date"      : "2015-09-15",
      "start"     : "2015-09-15 17:00:00+10",
      "loggedIn"  : "2015-09-15 17:06:27+10",
  }]
  </code></pre>