Skip to content

Instantly share code, notes, and snippets.

@dyazincahya
Created April 28, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyazincahya/746a9e65416c5a28d90f551c5e3de058 to your computer and use it in GitHub Desktop.
Save dyazincahya/746a9e65416c5a28d90f551c5e3de058 to your computer and use it in GitHub Desktop.
a simple function for check that is pangram text or not
function isPangram(sentence)
{
const setSentence = new Set(sentence.toLowerCase().replace(/[^a-z]/g,""));
return setSentence.size === 26;
}
const pangram = "The quick brown fox jumps over the crazy little dog";
alert(isPangram(pangram)); //true
const isPangram = (name) => {
return 'abcdefghijklmnopqrstuvwxyz'.split('').every(alphabet => name.toLowerCase().includes(alphabet));
}
let text = "The quick brown fox jumps over the crazy little dog";
alert(isPangram(text)); //true
let string = '!The quick brown fox jumps over the?lazy-dog.';
function isPangram(str) {
if (!str) return;
let res = str.toLowerCase()
.replace(/[^a-z]/g, '')
.split('')
.filter((val, id, self) => {
return self.indexOf(val) === id;
});
return res.length === 26;
}
alert(isPangram(string)); //true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment