javascript check if string contains only letters and spaces code example
Example: how to check if a string contains only spaces in javascript
let str = " ";
if (!str.replace(/\s/g, "").length) {
console.log("string only contains whitespace (ie. spaces, tabs or line breaks)");
}