Partition an array with one element into an array with many elements

I want to take this array containing one element (STRING with a bunch of comma separated elements)

["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"]

I want to turn this into this. An array containing each name as a separate element of the array.

["Bucknell Venture Plan Competition", "Mitch Blumenfeld", "DreamIt Ventures", "Deep Fork Capital", "John Ason", "Mitchell Blumenfeld", "Gianni Martire"]

Thanks!

UPDATE:

Thanks for the help. It worked!

+4
source share
2 answers

Simple as:

 var myArr = ["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"]; var myNewArr = myArr[0].split(","); 
+8
source

I think this should work:

 var items = ["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"]; var array = items[0].split(","); 
+4
source

Source: https://habr.com/ru/post/1412022/


All Articles