Shany  Jenkins

Shany Jenkins


JavaScript Algorithm: Detect Pangram

We are going to write a function called isPangram that accepts a string called string as an argument.

In this function, you are given a string and the goal of the function is to output true if that string is a pangram and false if it’s not. A pangram is a sentence that contains every single letter of the alphabet at least once.


"The quick brown fox jumps over the lazy dog." // true
"This is not a pangram." // false

The first thing we are going to do is lowercase our string and put it in a variable called strArr. It is easier to check all the letters in the string if everything is in lowercase.

let strArr = string.toLowerCase();
let alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');

Next, we create another variable called alphabet that will hold an array containing the English alphabets.

We create a for-loop and loop though alphabet.


JavaScript Algorithm: Detect Pangram