Created
April 28, 2018 10:42
-
-
Save dyazincahya/746a9e65416c5a28d90f551c5e3de058 to your computer and use it in GitHub Desktop.
a simple function for check that is pangram text or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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