So, I think I’ve got this. But I’m confused about why one of these passes and why the other doesn’t…
This does not pass.
function mutation(arr) {
for (var i = 0; i < arr[1].length; i++) {
if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) < 0) {
return false;
} else {
return true;
}
}
}
But this does.
function mutation(arr) {
for (var i = 0; i < arr[1].length; i++) {
if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) < 0)
return false;
}
return true;
}
Why is this? I thought best practice was to include curly braces after your if
statements.