Tell us what’s happening:
I was trying to solve this problem using regular expression but i could not find a way how to use a variable inside regex as /[str1]/ is there a way to do this please help.
**Your code so far**
function mutation(arr) {
let str = arr[0];
let str1 = arr[1];
let regex = /[str1]/gi;
if(str.match(regex)){
return true;
}
return false;
}
mutation(["hello", "hey"]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Thankyou for the information but, I am struggling to pass a string as a set of char so that it could be checked if these char exists in that string or not.
as i above code : i want to check if all the char in str1 which are[h,e,y] are present in str or not and to do so, i used /[str1]/; which did not work.