It is very simple to convert an array to CSV.
Suppose you have a JS array of strings like this:
var vegetables= [‘onion’, ‘ladyfinger’, ‘peas’];
var str = vegetables.valueOf();
onion, ladyfinger, peas