Answers for "javascript check fi string includes a space"

4

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
3

javascript detect space in string

if(str.indexOf(' ') >= 0){
    console.log("contains spaces");
}
Posted by: Guest on November-14-2020

Code answers related to "javascript check fi string includes a space"

Code answers related to "Javascript"

Browse Popular Code Answers by Language