Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2015 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/c5e5a41e802df45573b9 to your computer and use it in GitHub Desktop.
Save anonymous/c5e5a41e802df45573b9 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/dbess1 's solution for Bonfire: Mutations
// Bonfire: Mutations
// Author: @dbess1
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
var stringToArray1 = arr[0].toLowerCase().split(""); //h,e,l,l,o
var stringToArray2 = arr[1].toLowerCase().split(""); //h,e,y
for (i = 0; i < stringToArray2.length; i++) {
if (stringToArray1.indexOf(stringToArray2[i]) == -1) //if arr[0] and arr[1] do not equal
return false; //you get -1 accorrding to MDN
}
return true;
}
mutation(["hello", "hey"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment