javascript - need help in adding objects to array -
i fetching data text file , need in making information object..
array:
['celestine,timmy,celestinetimmy93@gmail.com,repeat 124\narun,mohan,reach@gmail.com,repeat 124213\njobi,mec,mec@gmail.com,rave\njalal,muhammed,jallu@gmail.com,rave1231212321\nvineeth,mohan,get,rave1231212321\n' ] i need values till \n in 1 object
expected result:
[{'celestine,timmy,celestinetimmy93@gmail.com,repeat 124} {arun,mohan,reach@gmail.com,repeat 124213} {jalal,muhammed,jallu@gmail.com,rave1231212321} {vineeth,mohan,get,rave1231212321} ]
you can in way.
after applying splitting '\n'
['celestine,timmy,celestinetimmy93@gmail.com,repeat 124\narun,mohan,reach@gmail.com,repeat 124213\njobi,mec,mec@gmail.com,rave\njalal,muhammed,jallu@gmail.com,rave1231212321\nvineeth,mohan,get,rave1231212321\n' ] you single 1 dimensional array.
["celestine,timmy,celestinetimmy93@gmail.com,repeat 124", "arun,mohan,reach@gmail.com,repeat 124213", "jobi,mec,mec@gmail.com,rave", "jalal,muhammed,jallu@gmail.com,rave1231212321", "vineeth,mohan,get,rave1231212321", ""] then looping each individual record.
js :
var test = ['celestine,timmy,celestinetimmy93@gmail.com,repeat 124\narun,mohan,reach@gmail.com,repeat 124213\njobi,mec,mec@gmail.com,rave\njalal,muhammed,jallu@gmail.com,rave1231212321\nvineeth,mohan,get,rave1231212321\n' ] var arrstring = []; test.foreach(function(val,key){ arrstring = val.split('\n') }); console.log(arrstring); arrstring.foreach(function(val,key){ console.log(val.split(',')); })
Comments
Post a Comment