How to check if a string is alphabetic include spaces in JavaScript

1 Answer

0 votes
function isAlphabetic(str) {
  	return /^[a-zA-Z() ]+$/.test(str);
}

console.log(isAlphabetic("javascript")); 
console.log(isAlphabetic("java script")); 
  
  
    
    
/*
run:

true
true
    
*/

 



answered Sep 18, 2021 by avibootz

Related questions

1 answer 217 views
1 answer 106 views
2 answers 199 views
199 views asked Aug 17, 2019 by avibootz
1 answer 76 views
...