jquery - Extra comma when concatenate JavaScript Arrays -


i trying write few javascript arrays csv file. however, need add line break @ locations. following code works, accidently add , first element in row 2 (or add , since row 2). wondering caused this? in advance!

current output

chemical, cas, mw , water, 00566, 666 

desire output

chemical, cas, mw water, 00566, 666 

code

var chem1 = "water" var cas1 = "00566" var mw1 = "666"  var csv_content = [] var csv_content_final = [] csv_content[0] = ["chemical, cas, mw"]; var chem_property = [chem1, cas1, mw1]; csv_content[1] = chem_property; (kkk = 0; kkk < ($(csv_content).size()); kkk++) {       csv_content_final[kkk] = csv_content[kkk] + '\n'; }  alert(csv_content_final) 

jsfiddle

the reason , because definition csv format 'comma separated values'

a new line not considered delimiter, comma.

edit:

if want not have comma @ start, work: console.log(csv_content_final.join(''));

http://fiddle.jshell.net/l8zdqo4u/

but not csv

enter image description here


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -