One could argue that if your input's data are nested to a higher level, you will have to adapt the flat() method accordingly, which is not an issue in your code.
But won't you be suppose to know the shape of the data you're working with ^^ ?
Thank you for your time and showing us that recursion is not terrifying !
Hello ^^. Nice use of recursion !
For the sake of discussion, here is another solution using built-in methods of Array :
One could argue that if your input's data are nested to a higher level, you will have to adapt the
flat()
method accordingly, which is not an issue in your code.But won't you be suppose to know the shape of the data you're working with ^^ ?
Thank you for your time and showing us that recursion is not terrifying !
Thanks for reading the article and for this solution 🙌. Really appreciate it. But yeah I covered this solution because it covers recursion as well.