JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
JavaScript
function createOutput() {
return _.reduce(arguments, function(memo, arr) {
return _.map(memo, function(val, index) {
return {
x: val.x,
y: val.y + arr[index].y
};
});
}, _.map(_.range(arguments[0].length), function(val) {
return {
x: val + 1,
y: 0
};
}));
}
console.log(createOutput(
[{x: 1, y: 2},{x: 2, y: 6},{x: 3, y: 2}],
[{x: 1, y: 5},{x: 2, y: 3},{x: 3, y: 6}]
));