In a json feed (below) I have two arrays, "rent" and "buy" I wish to join and display in an html table but I'm not sure where to do it.
The feed looks like this...
"store": {
"rent": [
{ "title": "Lord of the ring masters", "cost": 2.99 }
],
"buy": [
{ "title": "Fast and Furious 14", "cost": 5.99 },
{ "title": "Shogun Assassin", "cost": 2.99 }
],
"total": 30.20
}
And the render function in my view, which will display one of the above correctly looks like this
render: function(){
var createRow = function(rowItem, i){
return (
<tr key={i}>
<td>{rowItem.name}</td>
<td>{rowItem.cost}</td>
</tr>
);
};
return (
<div>
<h1>Package</h1>
<table className="table">
<thead>
<th>Package</th>
<th>Name</th>
<th>Cost</th>
</thead>
<tbody>
{this.props.packageList.rent.map(createRow, this)}
</tbody>
</table>
Total: {this.props.packageList.total}
</div>
);
}
Could any one tell me how I would alter the above to join the arrays and present the data like this...
**Rent** Lord of the ring masters £2.99
**Buy** Fast and Furious 14 £5.99
**Buy** Shogun Assassin £2.99