Why is there no way to REMOVE but not replace a character in a string?

I have an array of characters that for some reason is adding commas in between all it’s characters.

So if:

array[0] = undefined;
array[1] = “b”;
array[2] = “a”;
array[3] = undefined;

Then myArray.toString(); returns “,ba,” instead of “ba.”

I need to be able to get rid of those commas. It seemed like a simple “do a for loop” sort of solution, but I can’t find a function that will simply remove unwanted characters from a string, turning “,ba,” into “ba”. I can replace the characters, or I can specifically remove only the first or last letters, but sometimes the commas are in the middle of a word. My word might look something like “,r,a,in”.

Is it possible to remove just the undefined nodes from an array, or just the commas from a string?

Thanks! :slight_smile: