Append to string variable [closed]

2019-01-07 07:41发布

How can I append a word to an already populated string variable with spaces?

4条回答
贪生不怕死
2楼-- · 2019-01-07 07:51
var str1 = "add";
str1 = str1 + " ";

Hope that helps,

Dan

查看更多
我想做一个坏孩纸
3楼-- · 2019-01-07 07:57
var str1 = 'abc';
var str2 = str1+' def'; // str2 is now 'abc def'
查看更多
别忘想泡老子
4楼-- · 2019-01-07 07:58

Like this:

var str = 'blah blah blah';
str += ' blah';

str += ' ' + 'and some more blah';
查看更多
Melony?
5楼-- · 2019-01-07 08:02

Ronal, to answer your question in the comment in my answer above:

function wasClicked(str)
{
  return str+' def';
}
查看更多
登录 后发表回答