xxxxxxxxxx
const str = " Hello, World! ";
const trimmedStr = str.trim();
console.log(trimmedStr); // "Hello, World!"
xxxxxxxxxx
const str = "Hello, World! ";
const removedWhiteSpace = str.replace(/\s/g, "");
console.log(removedWhiteSpace); // Output: "Hello,World!"
xxxxxxxxxx
const str = " remove whitespace from string ";
const result = str.replace(/\s/g, "");
console.log(result);
xxxxxxxxxx
let name = " John Doe ";
let trimmedName = name.trim(); // Output: "John Doe"
xxxxxxxxxx
const str3 = " Hellow World! "
const str3Res = str3.trim() //"Hellow World!"