Creating Array of Array from string

Hey guys am a learner and I have a string which I want to convert to an array

var myString = 'one,two\nthree,four\nfive\nsix,seven'

I want to convert this to an array of array like below

var newArray = [['one','two'],['three','four'],['five'],['six','seven']]

In my newArray I want to convert the line break in myString to an array and also split the words and put them as individual elements in an array

I hope I see help

141 thoughts on “Creating Array of Array from string”

Leave a Comment