js slice and put spaces in code example Example: javascript replace spaces with br str = str.replace(/\s/g, "<br>");