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

**URL:** <https://forum.kirupa.com/t/why-is-there-no-way-to-remove-but-not-replace-a-character-in-a-string/324610>\
**Category:** flash\
**Created:** [August 30, 2011, 1:03am UTC](https://forum.kirupa.com/t/why-is-there-no-way-to-remove-but-not-replace-a-character-in-a-string/324610 "2011-08-30T01:03:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sogj](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sogj/32/3189_2.png) [@sogj](https://forum.kirupa.com/u/sogj)\
**Post date:** [August 30, 2011, 1:03am UTC](https://forum.kirupa.com/t/why-is-there-no-way-to-remove-but-not-replace-a-character-in-a-string/324610/1 "2011-08-30T01:03:23Z")

</div>

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! 🙂
