let arr1= ["2018-10-16", "2018-10-17"];
let arr2= [
]{
rate_of_finished_order: "37.54", order_average_amount: 60.53,
total_of_orders: 223118, total_of_finished_orders: 83756
},
{
rate_of_finished_order: "42.47", order_average_amount: 59.82,
total_of_orders: 210315, total_of_finished_orders: 89329
}
]
the desired objects are as follows:
{
2018-10-16: {
rate_of_finished_order: "37.54", order_average_amount: 60.53,
total_of_orders: 223118, total_of_finished_orders: 83756
},
2018-10-17: {
rate_of_finished_order: "42.47", order_average_amount: 59.82,
total_of_orders: 210315, total_of_finished_orders: 89329
}
}
the following is my code, please advise:
getTable (data) {
let obj = {}
let tableData = [];
let arr1 = Object.keys(data);
let arr2 = Object.values(data);
arr2. map(item=>{
// item.rate_of_finished_order = ((item.total_of_finished_orders/item.total_of_orders)*100).toFixed(2)
for(let i =0 ;i<arr1.length; iPP){
obj[arr1[i]] = item
}
tableData.push(obj)
//console.dir(obj)
})
this.setState({
tableData,
load: false,
});
}
the final console results are as follows:
{
2018-10-16: "[object Object]"
2018-10-17: "[object Object]"
2018-10-18: "[object Object]"
2018-10-19: "[object Object]"
2018-10-20: "[object Object]"
2018-10-21: "[object Object]"
2018-10-22: "[object Object]" < 10-24: "[object Object]"
2018-10-25: "[object Object]"
}
Why are all [object Object]?