how to remove spaces in given string in javascript code example Example: remove spaces in a string js str.replace(/\s+/g, '')