.DS_Store
# reduce-data-with-javascript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Plunker</title>
</head>
<body>
<script>
var originalConsoleLog = console.log
console.log = function () {
originalConsoleLog.apply(console, arguments)
var args = Array.prototype.slice.call(arguments);
document.body.innerText += args.join(' ') + '\n';
};
</script>
<script src="script.js"></script>
</body>
</html>
var data = ["vote1", "vote2", "vote1", "vote2"];
function reducer(accumulator, value) {
if (accumulator[value]) {
accumulator[value] = accumulator[value] + 1;
} else {
accumulator[value] = 1;
}
return accumulator;
}
var tally = data.reduce(reducer, {});
console.log("Vote1: ", tally.vote1)