xxxxxxxxxx
var string = " Hello World! "
console.log(string);
//" Hello World! "
string2 = string.trim();
console.log(string2);
//"Hello World!"
xxxxxxxxxx
const removeAllSpaces = (string) => {
const newText = string.replace(/\s+/g, "");
return newText
};
console.log(removeAllSpaces(" Hello World "));
//HelloWorld
xxxxxxxxxx
var name = "codepadding code ";
// remove all white spaces single or multiple spaces
var name = name.replace(/\s/g, '');
console.log(name)
//output
//mizanurrahmanmizan