Trying to determine if a variable contains all the strings from an array has proven trickier than expected. I've attempted various methods, but they all seem overly complex and unsuccessful. Any suggestions would be greatly appreciated.
For example:
var myArray = ["cat","dog","bird"];
var myString = "There is a cat looking the bird and a dog looking the cat";
var myString2 = "There is a cat and a dog looking one each other";
myArray and myString should return true, while myArray and myString2 should return false.
I've been experimenting with something like this:
var selector = "dir.class#id";
var code = '<div id="id" class="class"></div>';
var tokens = selector.split(/[\.,#]+/);
for (var i = tokens.length - 1; i >= 0; i--) {
var counter = [];
if (code.indexOf(tokens[0]) > -1 ) {
counter.concat(true);
}
}
Thank you!