Possible Duplicate:
String Manipulation - Javascript -
I have a string:
hello   and I want to add a space between each character to give:
h e l l o   What is the best way to do this?
To add a space between the characters of a string, call the split() method on the string to get an array of characters, and call the join() method on the array to join the substrings with a space separator, e.g. str. split('').
Use comma or just add space between them print("?" , d) print(e , '! ') OR print("?" +" "+ d) print(e +" "+'! ')
You can use the regular expression '..' to match each two characters and replace it with "$0 " to add the space: s = s. replaceAll("..", "$0 ");
"hello".split('').join(' '); // "h e l l o" 
                        var text = "hello"; var betweenChars = ' '; // a space  alert(text.split('').join(betweenChars)); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With