R
Reactiflux
help-js
✅ – 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.
The combined array would look like this:
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",
}
[{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]
are these two objects just separate variables? In that case you literally just do
const array = [obj1, obj2]
They are separate variables, I'll see what that does.
unfortunately, that just creates an array with the 2 objects
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 answersok, that makes sense
3 Messages Not Public
Sign In & Join Server To View
Looking for more? Join the community!
R
Reactiflux
help-js
R
Reactiflux
help-js
Want results from more Discord servers?
Recommended Posts✅ – Ygg – 22-32 Mar 8Hello, I'm using a `FreeCompanyContext` to use some variables across my website
One of then is usingVuNguyen – 12-56 Mar 8How do I create a virtual microphone, then pipe audio to it using NodeJS?VuNguyen – 05-04 Mar 8Hey, I'm currently looking for a way to create an output device with NodeJS, then other programs can