DEV Community

Discussion on: Untangling Nested Code

Collapse
 
alainvanhout profile image
Alain Van Hout

Typically, when you're transforming an array into another array, there is a specific task that you're trying to accomplish. The name of the new array could reflect that.

Beyond that, method extraction and functional programming can be your friend in these cases.

Collapse
 
gonedark profile image
Jason McCreary

As noted, definitely take a look at the array or collection functions available. The code you posted looks like it is a native group or flatten function.