Last active
January 25, 2016 01:07
-
-
Save Jacob-Bass/cbe2576e688884aa31fa to your computer and use it in GitHub Desktop.
FreeCodeCamp "Mutations" solution
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
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array. | |
For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case. | |
The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y". | |
Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien". | |
function mutation(arr) { | |
var y = [arr[0].toLowerCase(),arr[1].toLowerCase()]; | |
var x = y[1].split(""); | |
var ver; | |
for (var i=0;i<x.length;i++){ | |
if (y[0].indexOf(x[i])>=0){ | |
ver=true; | |
}else if(y[0].indexOf(x[i])<0){ | |
ver=false; | |
break; | |
} | |
} | |
switch(ver){ | |
case true: | |
return true; | |
case false: | |
return false; | |
} | |
} | |
mutation(["floor", "for"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment