Hey, I’m having trouble with this lab and I feel like I have it figured out… But for some reason this code isn’t working as intended. Can someone give me some insight on where I might’ve gone wrong? Or what I’m missing possibly. I’ve done tests and the if statement I feel like should be returning false for this but continues to return true.
function mutation(arr) {
var str1 = arr[0].toLowerCase();
var str2 = arr[1].toLowerCase();
var regexp = /[A-Za-z]/gi;
var match1 = str1.match(regexp);
var match2 = str2.match(regexp);
var sort1 = match1.sort();
var sort2 = match2.sort();
for (i = 0; i < str2.length; i++) {
if (sort1.indexOf(sort2[i]) === -1) {
return false;
}
return true;
}
}
mutation(["hello","hey"]);