JavaScript by Radu TM • June 22, 2022
// check if string contains any letter in javascript
function checkString(str) {
// regex to check if string contains any letter
const regex = /[a-zA-Z]/;
// return true if string contains any letter, false otherwise
return regex.test(str);
}
// test the function
console.log(checkString("🍕")); // false
console.log(checkString("pizza")); // true
0
25.740
JavaScript by Radu TM • June 22, 2022
const string = "I ❤️ JS";
// check if string contains any letter
const hasLetter = /[a-zA-Z]/.test(string);
console.log(hasLetter); // true
0
25.740