Skip to content
Advertisement

Write nested map function

I have an object like this:

JavaScript

Expected output :

JavaScript

And I already wrote a function like this:

JavaScript

I can write another function to flatten the output of the code above, but is there any other way to write the code above into a more general function (not hardcoded) that can apply to any object?

Advertisement

Answer

You can use a recursive function to get all permutations from the entries.

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