Answers for "how to check if a string contains only spaces in javascript"

2

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)");
}
Posted by: Guest on May-17-2021

Code answers related to "how to check if a string contains only spaces in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language