Mutations / Invalid flags supplied to RegExp

Tell us what’s happening:
Hi Everybody,

My console returns to me : Invalid flags supplied to RegExp constructor ‘a’.
I would like to understand what’s wrong?
The purpose of this function is to match the arr[1] arg into the arr[0] arg , unsorted.

Your code so far


function mutation(arr) {
  let cut = arr[1].split('');
  let cut2 = arr[0].split('');
  var regex = new RegExp(...cut, '\gi');
  var result = regex.test(...cut2);
console.log(result);
}
mutation(["Mary", "Aarmy"]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Acceptable flags are ‘gimsuy’. You have a backslash.

whithout , I still have the same problem.
Invalid flags supplied to RegExp constructor ‘a’

Yes, I just noticed. You’re splitting “Mary” and then passing it as arguments to RegExp. It takes first letter “M” as regex and second letter (“a”) as flag.