Hi, does this syntax exists in javascript? How can I pass an array value through a regex condition?
**Your code so far**
function mutation(arr) {
const regex = /arr[1]/gi; //see this line
const found = arr[0].match(regex);
console.log(found);
}
mutation(["hello", "hello"]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.
I get what you are trying to do but unfortunately it’s a far cry from how regex works.
You shouldn’t need regex to solve this challenge. I imagine some looping should suffice.
PS You can potentially solve this challenge using regex but you’ll need to use the regex constructor function and it’s still going to be an overcomplication i.e. not the best choice. And if you don’t know what I’m talking about then ignore this last bit of comment.