let para = document.createElement('p');
document.body.appendChild(para)
const apple = {
color: 'Green',
price: {
bulk: '$3/kg',
smallQty: '$4/kg'
}
};
let txt = ''
for (let x in apple) {
txt += apple[x]
};
para.innerHTML = txt;
In the browser, I'm getting Green[object Object] thank you
///////////////
In the 2nd iteration, you are getting an object which is why you are seeing such an output.
Convert apple[x] to a string using JSON.stringify(apple[x]) and this will be your output:
"Green"{"bulk":"$3/kg","smallQty":"$4/kg"}