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
...