I have an array that looks like this:
myArray = [[],[],[],[],['test', 'hello'], [], [], [['one', 'two'], ['three','four']], [], ['five']]
I need to remove all these empty objects and more unnecessary brack so my array look like:
['test','hello','one','two','three','four','five']
I tried the following:
myArray.removeAll(['[]'] as Object[])
My array then return 'false'. Any ideas how I could remove all the uncessary bracket?
CodePudding user response:
You can use myArray.flatten()
to get your expected result