dmikester1
dmikester117mo ago

✅ – dmikester1 – 19-47 Mar 14

I have 2 objects with the same keys. I want to combine the objects into a single array of objects.
questions: Object {​​
crossContamination: "Is cross contamination at an acceptable level?",
mixer6Production: "Is anything being produced in mixer 6?",
product: "What product are we producing?",
barrelsEmptiedOnPiles: "Any mixed overflow barrels emptied on piles?",
binsLabeledCorrectlyOnCatwalk: "Are bins labeled correctly on catwalk level and readable?",
binsLabeledCorrectlyOnGround: "Are bins labeled correctly on ground level and readable?",
​​comments: "Additional comments for product(s) concern or quality:",
​​crossContamination: "Is cross contamination at an acceptable level?",
foreignProducts: "What are the foreign product(s)?",
mixer6Production: "Is anything being produced in mixer 6?",
overflowBarrelsEmpty: "Are the overflow barrels empty?",
overflowInfo: "Additional information is required:",
paintFloorWetDry: "Is the plant floor wet or dry?",
product: "What product are we producing?",
​​properWeight: "Is scale set at the proper weight?",
}
​​
checkData: Object {
crossContamination: "No",
mixer6Production: "Yes",
product: "other one",​​
barrelsEmptiedOnPiles: "No",​​
binsLabeledCorrectlyOnCatwalk: "Yes",​​
binsLabeledCorrectlyOnGround: "No",​​
comments: "quality",​​
crossContamination: "No",​​
mixer6Production: "Yes",​​
overflowBarrelsEmpty: "Yes",​​
paintFloorWetDry: "Wet",​​
product: "other one",​​
properWeight: "No",
}
questions: Object {​​
crossContamination: "Is cross contamination at an acceptable level?",
mixer6Production: "Is anything being produced in mixer 6?",
product: "What product are we producing?",
barrelsEmptiedOnPiles: "Any mixed overflow barrels emptied on piles?",
binsLabeledCorrectlyOnCatwalk: "Are bins labeled correctly on catwalk level and readable?",
binsLabeledCorrectlyOnGround: "Are bins labeled correctly on ground level and readable?",
​​comments: "Additional comments for product(s) concern or quality:",
​​crossContamination: "Is cross contamination at an acceptable level?",
foreignProducts: "What are the foreign product(s)?",
mixer6Production: "Is anything being produced in mixer 6?",
overflowBarrelsEmpty: "Are the overflow barrels empty?",
overflowInfo: "Additional information is required:",
paintFloorWetDry: "Is the plant floor wet or dry?",
product: "What product are we producing?",
​​properWeight: "Is scale set at the proper weight?",
}
​​
checkData: Object {
crossContamination: "No",
mixer6Production: "Yes",
product: "other one",​​
barrelsEmptiedOnPiles: "No",​​
binsLabeledCorrectlyOnCatwalk: "Yes",​​
binsLabeledCorrectlyOnGround: "No",​​
comments: "quality",​​
crossContamination: "No",​​
mixer6Production: "Yes",​​
overflowBarrelsEmpty: "Yes",​​
paintFloorWetDry: "Wet",​​
product: "other one",​​
properWeight: "No",
}
6 Replies
dmikester1
dmikester117mo ago
The combined array would look like this:
[{id: "crosscontamination", question: "Is cross contamination at an acceptable level?", answer: "No"}, {id: "mixer6Production", question: "Is anything being produced in mixer 6?", answer: "Yes"}, etc]
[{id: "crosscontamination", question: "Is cross contamination at an acceptable level?", answer: "No"}, {id: "mixer6Production", question: "Is anything being produced in mixer 6?", answer: "Yes"}, etc]
Vanishy
Vanishy17mo ago
are these two objects just separate variables? In that case you literally just do const array = [obj1, obj2]
dmikester1
dmikester117mo ago
They are separate variables, I'll see what that does. unfortunately, that just creates an array with the 2 objects
Vanishy
Vanishy17mo ago
oh sorry, I misunderstood the question you want to iterate through the keys of the first object with Object.keys(obj1).map(key => { ... }) and inside the map you can have the logic to get questions and answers
dmikester1
dmikester117mo ago
ok, that makes sense
reactibot
reactibot17mo ago
This question has an answer! Thank you for helping 😄 If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1085288024121815201 This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1085288024121815201