Checks string for pangram #hackerrank #strings
/*
Solution for HackerRank > Algorithms > Strings > Pangrams
https://www.hackerrank.com/challenges/pangrams
*/
function main(input) {
var alpha = 'abcdefghijklmnopqrstuvwxyz';
var i = 0, char, index;
// Simplify string
var simple_input = input.toLowerCase().replace(/\s+/g, '');
/*
Test for each character in the alpha string.
If the character doesn't exist, break the loop and return 'not panagram'.
*/
for (i=0; i < alpha.length; i++){
char = alpha.charAt(i);
index = simple_input.indexOf(char);
if (index == -1){
console.log('not pangram');
break;
} else if (i == 25){
console.log('pangram');
}
}
}
main('We promptly judged antique ivory buckles for the next prize ');