My objective is to concatenate all values from an object using a semi-colon as separator. This process works perfectly when the object consists of just one level:
obj = {
name: "one"
additionalInfo: "hello"
...
};
Object.values(obj).join(';')
Output: one;hello
However, I encounter an issue when the object is nested:
obj = {
name: "one"
additionalInfo: {
description: "hello",
...
}
};
Object.values(obj).join(';')
Output: one;[object Object]
The values at level 2 (beyond name) are represented as [object Object]. How can I also join these nested values?
The desired result is:
one;hello