Created
December 4, 2015 20:30
-
-
Save anonymous/192fcbf735e60dc1cf3f to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/subodh737 's solution for Bonfire: Mutations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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