i want a help here since i cannot find a proper solution: I have two objects:
obj1 = {
name: '112',
surname: { test: '123', other: '124' },
age: 151,
height: '183',
weight: 80
};
and
obj2 = {
name: '114',
surname: { test: '124' },
age: 151,
height: 184,
weight: 81
};
The new object must have this output:
new = {
name: '114',
surname: { test: '124', other: '124' },
age: 151,
height: 184,
weight: 81
};
You can see that in the surname propert the other property is kept: I've tried something like this but it's not working and there must be a simpler solution:
const newObje = Object.keys(obj2).reduce(newObj, key) => {
if (typeof (obj2[key]) === 'string' || obj2[key] === 'number') {
newObj[key] = obj2[key];
}
if (typeof (obj2[key]) === 'object' || obj2[key] === 'array') {
}
}