var str = 'Welcom to StackHowTo.com!'; var str = str.replace(/ +/g, ' '); alert(str);
Welcom to StackHowTo.com!
However, the difference is not noticeable if you display this string of characters on a web page, because browsers treat multiple spaces as one space, unless you keep spaces.
MCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More