Skip to content
Advertisement

Append object parent key to children

I have the following object given:

JavaScript

I would like to append the parent object keys to all its array items like so:

JavaScript

How can I achieve this?

Advertisement

Answer

You can loop and set each item

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement