arr contains two strings, so arr is for the first string and arr is for the second string.
What you do actually is the following:
you take the second string (i.e. arr) you change to lowercase, then you split it (you will have an array), and you use the method every, to check if every element of the array satisfies the function (the function return true or false), if yes, the mutation function will return true else it will return false.
what the function inside the every method does is simply, checks if the first string contains the letter, (the letter is a variable that changes because The every method executes the provided callback function once for each element present in the array).
How does the function check? it take the first string , turns it to lowercase (because uppercase is not the same as lowercase), and then checks the index of letter inside the first string using the method indexOf(you can use indexOf on strings), the indexOf method return “-1” if the element is not found, so it is like writing the function like that
return (index of letter inside the first string) != -1;
// if (index of letter inside the first string) is not found (i.e -1), the expression becomes -1 != -1 which is false, then there is a letter missing, which means " the string in the first element of the array DOES NOT contain all of the letters of the string in the second element of the array"
TL;DR: the function simply checks if letter is present in the first string.
That solution is very…concisely…written. It’s short, and effective, and clear as mud as a learning tool.
So the first thing to understand is the code leading up to the every(...). That code takes the second string, converts it to a lowercase string, then turns that into an array of letters.
The function you’re asking about will be used on every letter in that array. .every(...) runs a function on each member of an array, and only returns true if they all return true. This is key. So the function inside there takes one letter, and checks if that letter is in the first string in arr. That’s all that function does - does this one letter occur in this string?
If that function returns true for the entire array of lowercase letters, then every returns true. If even one returns false, the while thing is false.
Often, when looking at a challenge like this, i try to simplify. “What if, instead of an array of things to test, i want to test one thing?” That’s easier to grok, and coding that can often be used as a small part of a bigger structure - an individual Lego in your castle.