var name = "codepadding code "; // remove all white spaces single or multiple spaces var name = name.replace(/s/g, ''); console.log(name) //output //mizanurrahmanmizan