-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisPangram.js
More file actions
31 lines (22 loc) · 814 Bytes
/
isPangram.js
File metadata and controls
31 lines (22 loc) · 814 Bytes
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
const isPangram = (input) => {
if (input.length < 26) {
return false;
}
input = input.toLowerCase();
// Remove spaces
input = input.split(' ').join('');
// Removing duplicates characters
let inputArr = [...new Set(input.split(''))];
// Remove special characters symbols
inputArr = inputArr.filter(item => item[0].charCodeAt(0) >= 97 && item[0].charCodeAt(0) <= 122);
const { length } = inputArr;
let alphabets = 'abcdefghijklmnopqrstuvwxyz';
for (let i = 0; i < length; i++) {
if (!inputArr.includes(alphabets[i])) {
return false;
}
}
return true;
}
console.log(isPangram('The quick brown fox jumps over the lazy dog'))
console.log(isPangram('Mr. Jock, TV quiz PhD., bags few lynx'))