Skip to content

Instantly share code, notes, and snippets.

@petergi
Last active December 28, 2023 05:50
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 petergi/131700cf5ebea7f16e14ff60f5dd8df0 to your computer and use it in GitHub Desktop.
Save petergi/131700cf5ebea7f16e14ff60f5dd8df0 to your computer and use it in GitHub Desktop.
Checks to see if a given sentence is a Pangram
/**
* Checks if a string is a Pangram.
*
* @param {string} string - The string to be checked.
* @return {boolean} Returns true if the string is a pangram, false otherwise.
*/
const isPangram = (string) => {
const alphabet = "abcdefghijklmnopqrstuvwxyz"
const lowerCaseString = string.toLowerCase()
for (let i = 0; i < alphabet.length; i++) {
const letter = alphabet[i]
if (!lowerCaseString.includes(letter)) {
return false
}
}
return true
}
isPangram("The quick brown fox jumps over the lazy dog.") //= true
isPangram("Sixty zippers were quickly picked from the woven jute bag.") //= true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment