Trying to eliminate commas from a string, except when they are enclosed in quotes.
var mystring = "this, is, a, test, example, \"i, dont know\", jumps" ;
var newchar = '';
mystring = mystring.split(',').join(newchar);// working correctly
document.write(mystring);
The output I currently have is:
this is a test example "i dont know" jumps
The expected output should be:
this is a test example "i, dont know" jumps
I have a few questions. How do I determine the index of a string so that commas are included inside quotation marks but not outside of them? I believe I need to use indexOf and substring, but I am unsure about the formatting. (Please avoid using regex as I am new to JavaScript and focusing on the fundamentals.)