Quantcast
Channel: Christian Heilmann
Viewing all articles
Browse latest Browse all 438

Pangram validator in one line

$
0
0

Source code

For a quiz, I am playing with Pangrams, sentences that have all 26 letters of the alphabet in them. Using Set and some RegEx it is a one-liner in JavaScript to validate them (split into two lines for readability…).


const isPangram = s => new Set(
s.toLowerCase().replace(/[^a-z]/g, ‘’)
).size === 26;

I’ve also put together a small tool for myself to write pangrams and check them whilst I type. You can see it in action here:

screen recording of the tool validating a sentence

Do you have a shorter solution?


Viewing all articles
Browse latest Browse all 438

Trending Articles