Created
August 19, 2016 06:13
-
-
Save fercreek/82e4d1bed69ff695aeea02249af2f647 to your computer and use it in GitHub Desktop.
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
| /* | |
| 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) { | |
| count = 0; | |
| arr[0] = arr[0].split("").map(function(x){return x.toLowerCase();}).join(""); | |
| var status = arr[1].split("").every(function(e){ | |
| return arr[0].indexOf(e.toLowerCase()) >= 0 ? true:false; | |
| }); | |
| return status; | |
| } | |
| mutation(["hello", "Hello"]); | |
| // mutation(["hello", "hey"]) should return false. | |
| // mutation(["hello", "Hello"]) should return true. | |
| // mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) should return true. | |
| // mutation(["Mary", "Army"]) should return true. | |
| // mutation(["Mary", "Aarmy"]) should return true. | |
| // mutation(["Alien", "line"]) should return true. | |
| // mutation(["floor", "for"]) should return true. | |
| // mutation(["hello", "neo"]) should return false. | |
| // mutation(["voodoo", "no"]) should return false. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment