I have a string:
var myStr = 'This is a test';
I would like to make it comma delimited via JavaScript, like so:
var myNewStr = 'This, is, a, test';
What is the best way to accomplish this via JavaScript?
I know I can trim the commas like so:
var myStr = myNewStr.split(',');
And that would give me this:
myStr = 'This is a test';
But I am wanting to do the opposite of course, by adding commas.
'This is a test ', should it become'This, is, a, test, '?