I do have an object containing several nested dom elements, each of them have tagName and attributes that contains class name and either children or body, if its an array that means it has a children and there is more HTML tags, if its body that's a string which has to be placed between the tag element, so I need to write a function that takes an object and returns a string
const obj = { "tagName":"div", "attr":{"class":"container"}, "children":[
{ "tagName":"div", "attr":{"class":"row"}, "children":[{ "tagName":"h1",
"attr":{"class":"title"}, "body":"Hello" }] }] }
and result like this as string:
<div class='container'> <div class='row'> <h1 class='title'> Hello</h1> </div> </div>
JSON.stringify(obj);