希望我能正确地措辞。
我有一个数组:
var thisArray = ["This","That","This and That","This, That or Something Else"];
我想要做的是将其转换为字符串,转换后,将所有逗号分隔符替换为break标记,但保留每个值中的逗号。
现在,我有这段代码:
var thisArray = ["This","That","This and That","This, That or Something Else"];
var thisString = thisArray.toString();
var thisResult = thisString.replace(",","<br/>");
return thisResult;
但是,当然,通过这种方式,我会得到一个实际结果:
This
That
This and That
This
That or Something Else
当我想要结果
时This
That
This and That
This, That or Something Else
我需要做些什么来实现这一目标?
答案 0 :(得分:0)
您可以使用任何东西作为分隔符加入数组:
return thisArray.join('<br />')