I'm trying to get an array from two different arrays. I'm not sure how to do it with ES6.
I want the current_year_data
is replacing to previous_year_data
The First array is:
let previous_year_data = [
{ month: "January", value: 300 },
{ month: "February", value: 1 },
{ month: "March", value: 2 },
{ month: "April", value: 3 },
{ month: "May", value: 4 },
{ month: "Jun", value: 5 },
{ month: "July", value: 6 },
{ month: "August", value: 7 },
{ month: "September", value: 8 },
{ month: "October", value: 9 },
{ month: "November", value: 10 },
{ month: "December", value: 11 },
];
Second array:
let current_year_data = [
{ month: "January", value: 4459 }
];
The result should be in:
let current_year_data = [
{ month: "January", value: 4459 },
{ month: "February", value: 1 },
{ month: "March", value: 2 },
{ month: "April", value: 3 },
{ month: "May", value: 4 },
{ month: "Jun", value: 5 },
{ month: "July", value: 6 },
{ month: "August", value: 7 },
{ month: "September", value: 8 },
{ month: "October", value: 9 },
{ month: "November", value: 10 },
{ month: "December", value: 11 },
];
Thanks