Skip to content
Advertisement

How to transform nested object of objects into array of objects

Hi all I have the following code

the data that I want to transform.

JavaScript

In my obj variable I have 3 other objects

numbers object which has items property which includes 2 other objects.

letters object which has items property which includes only one object.

signs object.

I need to transform my obj to the following way.

JavaScript

for that transformation, I wrote the following code.

JavaScript

Everything was working, but for children instead of printing an array it prints undefined.

Please help me to resolve this issue.

Advertisement

Answer

I created a function for your case.

JavaScript

You can use like const items = convert(obj).

Advertisement