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