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:
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
false), if yes, the mutation function will return true else it will return false.
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.