Which code should I use on js to map an array with spliting cells yet not reapeating ["12,3","3","5","66,22"] into ["12","3","5","66","22"].
-
This is not a place where you can ask us to write code for you. First tell us what you have tried and if you tried what issue you are facing. Please go through what kind of questions you can ask hereSumanth Shastry– Sumanth Shastry2017-04-20 16:21:00 +00:00Commented Apr 20, 2017 at 16:21
Add a comment
|
4 Answers
I believe that you miss one 3 element in your desired output, if so - try following solution:
var arr = ["12,3","3","5","66,22"],
res = [].concat(...arr.map(v => v.split(',')));
console.log(res);
1 Comment
Karl Reid
He says 'not reapeating' so he probably wants the result to be unique. I guess you could use a Set to do that easily
res = Array.from([...new Set(res)])