Hello guys. How can I append a word to an already populated string variable with spaces?
A:
var str1 = 'abc';
var str2 = str1+' def'; // str2 is now 'abc def'
James Skidmore
2009-08-17 13:59:28
it's more of a onclick append to variable. can it be done with a single variable?
Ronal
2009-08-17 14:00:59
Sure thing. See my other answer below.
James Skidmore
2009-08-17 14:02:43
@Ronal - if there are any extra bits to your question, you should add them to the question rather than asking within the comments, including any information that might help you get a decent answer.
karim79
2009-08-17 14:03:32
no problem. much thanks
Ronal
2009-08-18 19:27:11
+5
A:
Like this:
var str = 'blah blah blah';
str += ' blah';
str += ' ' + 'and some more blah';
karim79
2009-08-17 14:00:08
A:
Ronal, to answer your question in the comment in my answer above:
function wasClicked(str)
{
return str+' def';
}
James Skidmore
2009-08-17 14:02:36