javascript – Search if the characters of one string are present in another string

I have to match if the characters of a string are present in a haystack with the following conditions:

  • If match string contains repeated characters, haystack must contain several characters. In case of Hello haystack must contain at least 2 l.
  • Insensitive character.
  • Insensitive order.

The example below worked well for me because I managed every use case. Can we do it better with the least complexity? Or maybe without built-in functions like Index of, comprises, subsoil. Although I agree with map, filtered like functions.

function tableau_diff (tableau1, tableau2) {
return array1.filter (e => array2.indexOf (e) === -1)
}

compare function (haystack, match) {
const haystackArr = haystack.toLowerCase (). split (& # 39;);
const matchArr = match.toLowerCase (). split (& # 39;);

return haystackArr.length> = array_diff (haystackArr, matchArr) .length + matchArr.length;
}

console.log (compare ("aldhedalfkjlhdlkjohd," hello "));