Basic Algorithm Scripting - Mutations

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

Challenge: Basic Algorithm Scripting - Mutations

Link to the challenge:

There is a class called RegExp which would support using variables in the pattern.

If you do a google search, you will see examples like this (the pattern is a string so you can construct it with a variable)

var replace = "regex\\d";
var re = new RegExp(replace,"g");

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.

There is a way to do that as well with Regexp

Look at the search function….