function mutation(arr) {
//build a regexp
var regStr = "";
arr[1].split("").forEach(function(val){
regStr +="(?=.*?"+val.toLowerCase()+")";
//just like this "/(?=.*?a)(?=.*?b)(?=.*?c)/"
});
var regObj = new RegExp(regStr,"i");
return regObj.test(arr[0]);
}
mutation(["hello", "hey"]);refer to this blog