I'm doing a basic algorithm scripting challenge on FCC and I want to return true
if a string in a first element of an array contains all of the letters of the string in the second element of the array, or false
otherwise.
I've written some code for this. However I can't seem to pass one test:
mutation(["hello", "Hello"])
I've tried removing the global flag and have tried using constructor notation and literal notation based on recommendations from the FCC community, but to no avail.
This is the code:
function mutation(arr) {
let patt = new RegExp("[arr.1]", "i");
return patt.test(arr[0]);
}
mutation(["hello", "Hello"])
The function is supposed to return true
instead it returns false
. What is wrong with my code?