I have completed the challenge and passed all the tests using regex but I’m unclear on my solution as it seems messy. I’m not sure if this is the right place to look for feedback(or if that is a thing at all) so please remove if that’s the case.
Basically I’m looking for someone experienced to tell me if my solution is bad and why or why not
function mutation(arr) {
for(let i = 0; i < arr[1].length; i++){
var myReg = new RegExp(arr[1][i], 'i')
var checkLetter = myReg.test(arr[0])
if(!checkLetter){
return false
}
}
return true
}
mutation(["hello", "Hello"]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
It looks great, I don’t see any actual issues. I personally find it quite clear and not messy. If I were to actually nitpick I would:
have proper indentation (though I’m not sure if this is due to copy/paste issue)
use let/const instead of var (not sure if you learned that at this point)
use String.prototype.indexOf() instead of regExp as usually that would be faster for plain string matching. (but this makes such a minimal difference I feel odd even pointing it out)
I can see that you have great use of whitespace, descriptive variable names, clear and easy to follow code. This is really good work. Good job!