-3

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>
2
  • JSON.stringify(obj); Commented May 16, 2022 at 13:37
  • The question is correct there is no need to close it. Commented May 16, 2022 at 13:41

1 Answer 1

-3

JSON.stringify(value)

try this

Sign up to request clarification or add additional context in comments.

1 Comment

This would not yield the specified result.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.