Looking to merge key value pairs from one JSON object into another.
I've searched through various stackoverflow threads for solutions, but haven't found one that works for my specific scenario.
const primaryObject = {
name: "John Doe",
age: 30,
city: "New York"
}
var secondaryObject = {
details: {}
};
for (var key in primaryObject) {
if (primaryObject.hasOwnProperty(key)) {
secondaryObject.details[key] = primaryObject[key];
}
}
console.log(secondaryObject);