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?
"hello".split('').join(' '); // "h e l l o"
var text = "hello";
var betweenChars = ' '; // a space
alert(text.split('').join(betweenChars));
try:
var hello = 'hello';
var test = '';
for(var i=0; i<hello.length; i++){
test += hello.charAt(i) + ' ';
}
alert(test);
精彩评论