checks through an array of regexs to see if they match a string.
//checks if any of the words are present in the beginning of a sentence
function check_all(string) {
var words = [/what .+/, /why .+/, /how .+/];
for(var num in words) if(string.match(words[num])!==null) return "found match";
return "no match";
}
function test1() {
return check_all("how do clocks work") == "found match" ? "passed" : "failed";
}
console.log(test1());
// passed