I have 2 different objects, with the same properties which i want to concatenate:
obj1 = {id: "1: identifier 1 \n", description: "1: description 1 \n", ...., propertyX1} obj2 = {id: "2: identifier 2 \n", description: "2: description 2 \n", ...., propertyX2} My result should be:
obj1 = {id: "1: identifier 1 \n 2: identifier 2 \n", description: "1: description 1 \n 2: description 2", ...., propertyX1|propertyX2} My solution so far is:
function combineElements(element1, element2){ var property1, property2; for (property1 in element1) { if(element1.hasOwnProperty(property1)) {//bonus question: why does intellij ask me to add this? property2 = element2.getSameProperty(property1); // <<<<<<how do I iterate this? property1 = "\n" + property2; } } return element1; } How would you get the exact same property of the second element?
element2[property1]propertyX1andpropertyX2?