.DS_Store
# reduce-data-with-javascript
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Plunker</title>
</head>
<body>
  <script>
    // Allows Plunker to display logs in preview panel 
    // for better in-browser experience
    var originalConsoleLog = console.log
    console.log = function () {
      originalConsoleLog.apply(console, arguments)
      var args = Array.prototype.slice.call(arguments);
      document.body.innerText += args.join(' ') + '\n';
      document.body.style['fontFamily'] = 'monospace';
      document.body.style['fontSize'] = '2em';
    };
  </script>
	<script src="script.js"></script>
</body>
</html>
//see CONSOLE!
var votes = [
  "angular",
  "angular",
  "react",
  "react",
  "react",
  "angular",
  "ember",
  "react",
  "vanilla"
];

var initialValue = {};

var reducer = function(tally, vote) {
  if (!tally[vote]) {
    tally[vote] = 1;
  } else {
    tally[vote] = tally[vote] + 1;
  }

  return tally;
};

var result = votes.reduce(reducer, initialValue);

// Output
console.log("Angular: ", result.angular)
console.log("React: ", result.react)
console.log("Ember: ", result.ember)
console.log("Vanilla: ", result.vanilla)