My code works for each example, except the first one. Why is it happening? I used new RegExp, I know it’s probably not the best solution, but I came so far in this code, I don’t want to leave it almost ready.
Your code so far
function mutation(arr) {
var a = arr[0].toLowerCase();
var b = arr[1].toLowerCase().split('');
for(var i=0;i<=b.length;i++){
var c = new RegExp(b[i]);
var x = c.test(a);
if (x>0) {return true;}
return false;
}
}
mutation(["hello", "hey"]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36 OPR/47.0.2631.55
.
Link to the challenge: