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?
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?
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);
© 2022 - 2024 — McMap. All rights reserved.