var obj = [{
"position": "Bottom Left",
text: "2"
}, {
"position": "Top Center",
image: logo,
width: 22
}, {
"position": "Bottom Right",
text: "1"
}, {
"position": "Top Left",
text: "9"
}];
I'm trying to join using position
key with two other object arrays(pdf_header
and pdf_footer
) and save the remaining object key values in pdf_header_output
and pdf_footer_output
respectively. If the value is not present in obj
, then an empty object should push.
var pdf_header = [{
"position": "Top Left"
}, {
"position": "Top Center"
}, {
"position": "Top Right"
}];
var pdf_footer = [{
"position": "Bottom Left"
}, {
"position": "Bottom Center"
}, {
"position": "Bottom Right"
}];
Expected Output:
var pdf_header_output = [{
text: "9"
}, {
image: logo,
width: 22
}, {}];
var pdf_footer_output = [{
text: "2"
}, {}, {
text: "1"
}];
I tried this, but didn't work as expected