JSFiddle - React, Tailwind, and code Playground

JavaScript

function takeString (str) {
    var regex = "/^[A-Za-z]+$/";

    if (str.match(regex)) {

       if (str.charCodeAt(0) === str.toUpperCase().charCodeAt(0)) {
          alert('true');
          return true;
       } else {
          alert('false');
          return false;
       }
        
    } else {
        alert('Only letters please.');
    }
}
    
takeString('string');