We have a 2D array:
let userGroup = [
['user1-', 'user2-', 'user3-'],
['user4-', 'user5-', 'user6-'],
['user7-', 'user8-', 'user9-']
];
How can we create a single array from it and remove the "-" symbol at the end of each element?
The desired output is: ['user1, 'user2', 'user3', 'user4', 'user5', 'user6', 'user7', etc...]
Moreover, how can we write a function that can handle any number of inner arrays in the "userGroup" array? For instance, if there are unexpected inner arrays with more users (['user11', 'user12', 'user13], etc.), how do we create a function that takes the "userGroup" array as input and achieves the same result (remove the last "-" in each element and combine all elements in the inner arrays into one array)?