I have a string that contains multiple spaces. I want to replace these with a plus symbol. I thought I could use
var str="a b c";
var replaced = str.replace(' ', '+');
but it only replaces the first occurrence. How can I get it replace all occurrences?