Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2015 20:30
Show Gist options
  • Save anonymous/192fcbf735e60dc1cf3f to your computer and use it in GitHub Desktop.
Save anonymous/192fcbf735e60dc1cf3f to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/subodh737 's solution for Bonfire: Mutations
// Bonfire: Mutations
// Author: @subodh737
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
//-- Both elements to different vars
var str1 = arr[0].toLowerCase();
var str2 = arr[1].toLowerCase();
//-- Split & sort the chars
var arr1 = str1.split("");
var arr2 = str2.split("");
//--
for (var i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) < 0) {
return false;
}
}
return true;
}
mutation(["Hello", "hey"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment