Prevent Html Removing Successive Spaces
I have an issue in a JSP page where I have to display a generated message onscreen based on a string. It all works fine until one of the account numbers contains two spaces. So, I
Solution 1:
white-space: break-spaces solved for me. More on white-spaces here. They have this awesome table:

Solution 2:
functionencodeWhiteSpaces(str) {
return str.split('').map(function(c) { return c === ' ' ? ' ' : c }).join('');
}
The string is converted to an array(split), then created a new arrray (map) with all white spaces converted to , finally join the array back to a string (join).
Post a Comment for "Prevent Html Removing Successive Spaces"