.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>
var data = [15, 3, 20];
var reducer = function(accumulator, item) {
return accumulator + item;
};
var initialValue = 0;
var total = data.reduce(reducer, initialValue);
console.log("The sum is: ", total);