Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2015 05:36
Show Gist options
  • Select an option

  • Save anonymous/fafb0623b664a095d349 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/fafb0623b664a095d349 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Mutations
// Bonfire: Mutations
// Author: @goteamtim
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
var wordToSearchIn = arr.shift();
var seedWord = arr[0];
//Loop through each letter of first word
for(var i = 0; i < seedWord.length; i++){
var found = false;
//Loop through each letter of second word and search for the letter in the first
for(var j = 0; j < wordToSearchIn.length; j++){
//Will loop through one letter of first word per iteration
if(seedWord.charAt(i).toLowerCase() === wordToSearchIn.charAt(j).toLowerCase()){
found = true;
}
}
if(!found){
return found;
}
}
return found;
}
mutation(["hello", "helloO"]);
mutation(["hello", "helloO"]);
mutation(["hello", "hey"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment