In a health practice focused application I need to check whether one array is present inside another. Match conditions are: * It doesn't matter if there are additional non matching elements * It doesn't matter if a term appears more than once in the "haystack" array
We found a great solution in Lodash discussion. It is mocked up in JSFiddle and seems to work well.
But inside the rather complicated application it blows the browser apart using Lodash
Various configurations
This is the code that works with Lodash.
let haystack = ['health tips','iridology','something else','asdfasd'];
let needle = ['iridology','health tips'];
alert(_.intersection(needle,haystack).length === needle.length);
Does anyone know of a straightforward way of doing this in plain Javascript?