function testForLetter(character) {
try {
//Variable declarations can't start with digits or operators
//If no error is thrown check for dollar or underscore. Those are the only nonletter characters that are allowed as identifiers
eval("let " + character + ";");
let regExSpecial = /[^\$_]/;
return regExSpecial.test(character);
} catch (error) {
return false;
}
}
console.log(testForLetter("!")); //returns false;
console.log(testForLetter("5")); //returns false;
console.log(testForLetter("ن")); //returns true;
console.log(testForLetter("_")); //returns false;
// to check if the given string contain alphabets
function isPangram(sentence){
let lowerCased = sentence.toLowerCase();
let letters = "abcdefghijklmnopqrstuvwxyz";
// traditional for loop can also be used
for (let char of letters){
if (!lowerCased.includes(char)) return false;
}
return true;
}