I have a list that contains multi-level nested lists. Each list may contain strings and other type instances.
eg.
var list = [ 'a', 'w', ['e', ['f', new Object(), 'f'], 'g'], 't', 'e'];
I want to write a function (say compress) to merge strings with my siblings, as well as leave other instances of the type intact and finally get a list that doesn't have a nested list.
compress (list) {// how? }
And the result compress(list)will be:
['awef', new Object(), 'fgte']
Is this a quick and clear solution?
source
share