Mutations(Spoiler: Solution)

:smiley: I felt so happy when I solved this challenge, then came here and saw how elegantly many of you fellow campers solved it. It’s fun how many ways there are to solve a problem. Here’s my, rather verbose, solution. Any suggestions for improvement much appreciated :slight_smile:

function mutation(arr) {

// create arrays to house characters of strings we want to compare
var arr1 = ;
var arr2 = ;

// create array for characters that are present in both strings
var arr1_1 = ;

// split strings to compare into arrays
arr1 = arr[0].toLowerCase().split(“”);
arr2 = arr[1].toLowerCase().split(“”);

for (var i = 0; i < arr2.length; i++) {

// check if arr1 includes each character from arr2
if (arr1.includes(arr2[i])) {
  
  // if arr2(i) is found in arr1 push it to a new array
  arr1_1.push(arr2[i]);
}

}

// join arr1_1 into a string
var strToCompare = arr1_1.join([separator = “”]);

// compare the new string to arr[1]
if (arr[1].toLowerCase() == strToCompare) {
return true;
}
return false;

}