Added check pangram algorithm

This commit is contained in:
garifullin_aa
2020-10-16 15:01:39 +05:00
parent 4a26347767
commit 54198ac314
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,22 @@
/*
Pangram is a sentence that contains all the letters in the alphabet
https://en.wikipedia.org/wiki/Pangram
*/
const checkPangram = (string) => {
if (typeof string !== 'string') {
throw new TypeError('The given value is not a string')
}
const frequency = new Set()
for (const letter of string.toLowerCase()) {
if (letter >= 'a' && letter <= 'z') {
frequency.add(letter)
}
}
return frequency.size === 26
}
export { checkPangram }