Check whether a string is a Pangram or not.

What is a Pangram string?

The string is called a pangram if it contains all the alphabets from a to z or A to Z.

Example of Pangram Strings or Sentences. “The quick brown fox jumps over the lazy dog”.

Program.
var str = "The quick brown fox jumps over the lazy dog.";
var alphabets = new Set(str.toLowerCase()); 
let count =0; 
if(alphabets.size>0){
for(let c of alphabets){		 
    if (c >= "a" && c <= "z"){    	
    	count++;
    }    
}
} 
 
if(count == 26){
    console.log('String is Pangram');
}else{
  console.log('String is not a Pangram');
}

Output: “String is Pangram”.

Back to top button