How to combine splitting data using split function
2 answers
You can change the original line
var date = "2010-02-02";
var formatted_date = date.replace(/-/g, ',');
Note that the flag g
must be used to replace all instances of '-'.
Or you can create a new string from the array you created from the original split
var split_date = date.split('-');
...
var formatted_date = split_date.join(',');
0
a source to share