# freeCodeCamp Challenge Guide :Basic Algorithm Scripting: Mutations

Using Regular Expression( `RegExp`) as a solution.

``````function mutation(arr) {
return arr[1].match(RegExp(`[\${arr[0]}]`,'gi')).length===arr[1].length;
}
``````

#### Code Explanation

Created a Regular Expression using The RegExp constructor function with `[]` which Match any character in the set, with global search `g` and ignore case `i` flags.

The `match()` method retrieves all elements that were matched using with the RegExp in an array format.
The `length` property of an object which is an instance of type Array sets or returns the number of elements in that array.
The strict equality operator `(===)` checks whether its two operands are equal, returning a Boolean result.

In short, we create RegExp using all the characters from `index 0` of the array and find which characters which match with characters from `index 1` of the array.
A new array is created with all the matched characters.
We get length of that new array and compare it with the length from the original array of `index 1`. If both length match (True) else (False).