Pangram validator in one line

By admin
Pangram validator in

one
CARDINAL

line

Monday, November 6th,
DATE


2023
DATE

at

2:36 pm
TIME

For a quiz, I am playing with

Pangrams
GPE

, sentences that have all

26
CARDINAL

letters of the alphabet in them. Using Set and some RegEx it is a

one
CARDINAL

-liner in

JavaScript
PRODUCT

to validate them (split into

two
CARDINAL

lines for readability…).

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

26
CARDINAL

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

26
CARDINAL

;

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:

Do you have a shorter solution?