Last active
December 28, 2023 05:50
-
-
Save petergi/131700cf5ebea7f16e14ff60f5dd8df0 to your computer and use it in GitHub Desktop.
Checks to see if a given sentence is a Pangram
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
/** | |
* 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