For some reason, toLowerCase() won’t work for the individual characters in arr[1]. It works when I put variables for them but it doesn’t when I don’t set them to var.
function mutation(arr) {
arr[0].toLowerCase();
arr[1].toLowerCase().split('');
for (var i = 0; i < arr[1].length; i++) {
if (arr[0].indexOf(arr[1][i]) == -1) {
return false;
}
else {
continue;
}
}
return true;
}
String function toLowerCase does not change your string. It returns a new string that you will have to capture in a variable.
var myString = "You're Almost There!";
var newString = myString.toLowerCase();
console.log(myString); // "You're Almost There!" - unchanged even after .toLowerCase()
console.log(newString); // "you're almost there!" - saved changes to a new string
// saved changes to array of strings
var newArray = myString.toLowerCase().split("");
console.log(newArray);
// ["y", "o", "u", "'", "r", "e", " ", "a", "l", "m", "o", "s", "t", " ", "t", "h", "e", "r", "e", "!"]
I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
