so Pangrams are strings that have all the alphabet in them, so the website askes to make a piece of code that returns true if a given string is a pangram or false otherwise.
i solved it but my solotion is realy long, then i checked other solutions and found at the top a solution that is no more then 4 lines of code.
the solution have a comparison that i don’t understand.
function isPangram(string){
string = string.toLowerCase();
return "abcdefghijklmnopqrstuvwxyz".split("").every(function(x){
return string.indexOf(x) !== -1;
});
}
can somebody explain why he or she compared string.indexOf(x) to !== -1 and how will that check if all alphabets are in the string given to the function?
thank you