-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDetect Panagram.js
35 lines (24 loc) · 1.07 KB
/
Detect Panagram.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant).
// Given a string, detect whether or not it is a pangram. Return True if it is, False if not. Ignore numbers and punctuation.
function isPangram(string) {
const alphabetList = [...'abcdefghijklmnopqrstuvwxyz'];
return alphabetList.every((letter) => string.toLowerCase().includes(letter));
}
or
function isPangram(string){
string = string.toLowerCase();
return "abcdefghijklmnopqrstuvwxyz".split("").every(function(x){
return string.indexOf(x) !== -1;
});
}
or
function isPangram(string){
//...
let correct = string.toLowerCase().split('');
let az= 'abcdefghijklmnopqrstuvwxyz'.split('');
for (let letter of correct)
for (let x=0; x < correct.length; x++)
if (letter == az[x]) az[x]= "";
az= az.filter(value=> value !== '');
return !az.length ? true : false;
};