I have a list of names into text file and i need to convert to json every 2 lines .
const rawList = `*******Arn*******Brn*******Crn*******D`
const dataList = rawList.split('rn');
for (i = 0; i < dataList.length; i++) {
var masterlist = JSON.stringify(dataList[i]);
console.log(masterlist)
}
Output :
"*******A"
"*******B"
"*******C"
"*******D"
…
What i need:
["*******A","*******B"]
["*******C","*******D"]
…
2
Answers
let say you store all of
Output
in an array calledarr
Several issues, you just split and then stringify the result.
Here is a split and a push to new arrays