Created
December 4, 2015 02:26
-
-
Save anonymous/c5e5a41e802df45573b9 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/dbess1 's solution for Bonfire: Mutations
This file contains 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: @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