How to check if a string is alphabetic 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
false
    
*/

  

 



answered Sep 18, 2021 by avibootz

Related questions

...