A pangram is a sentence that contains every single letter of the alphabet at least once.
Here is my code so far:
const isPangram = (string) => {
let alpha = string.toUpperCase().split("");
for (let beta = 65; beta < 65 + alpha.length; beta++) {
let gamma = String.fromCharCode(beta);
if (alpha.includes(gamma)) {
continue;
}
else {
return false;
}
}
return true;
}
console.log(isPangram("Detect Pangram"));
Why does "Detect Pangram" return true?
You can do that very simple way with .every
as shown below.
alphabets = 'abcdefghijklmnopqrstuvwxyz'.split("");
const isPangram = (string) => {
string = string.toLowerCase();
return alphabets.every(x => string.includes(x));
}
console.log(isPangram("Detect Pangram"));
console.log(isPangram("abcd efgh ijkl mnop qrst uvwx yz"));
You can learn more about every
from below links.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With