Remove all characters other than alphabets from string | function to remove characters and print new string ; Store only valid characters ; driver code
function removeSpecialCharacter ( str ) { let s = str . split ( " " ) ; let j = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( ( s [ i ] >= ' ' && s [ i ] <= ' ' ) || ( s [ i ] >= ' ' && s [ i ] <= ' ' ) ) { s [ j ] = s [ i ] ; j ++ ; } } document . write ( ( s ) . join ( " " ) . substring ( 0 , j ) ) ; } let s = " " ; removeSpecialCharacter ( s ) ;