Liz Anaya Ramos
 · Developer Community Manager @ Xano

Challenge #31 - Flatten a Multi-Dimensional Array

Objective: Create a multi-dimensional array and flatten it into a single-dimensional array.

Instructions:

  1. Define the Multi-Dimensional Array:

    • Create an array variable named nested_array and assign it the values [[1, 2, 3], [4, 5], [6, 7, 8, 9]].

  2. Flatten the Array:

    • Create a new variable named flattened_array and use a filter to combine all the elements from the sub-arrays in nested_array into a single, flat array.

  3. Submit the array contained in the variable flattened_array.

Expected Result:

Submit the variable flattened_array as your answer. See example below:


Install the snippet to get started: https://www.xano.com/snippet/XwN5GThx