Reputation: 318
How to split 2nd value in array?
Input [["ABCD","123,456"],["EFGH","565,565,878"]]
Required Output [["ABCD","123","456"],["EFGH","565","565","878"]]
I tried array.map(x => x[1].split(','))
but I am getting output as [["123","456"]],["565","565","878"]]
1st value is getting omitted. How to include 1st value also?
If I use x.split(',')
I am getting error
x.split is not a function
Upvotes: 1
Views: 101
Reputation: 866
Try this
input.map(([name, list])=>[name, ...list.split(',')])
Upvotes: 4