regular expression to remove the space code example Example: regex to remove spaces //.. return str.replace(/\s/g, ''); //..