Skip to content

Instantly share code, notes, and snippets.

@bflannery
Created December 22, 2016 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bflannery/dd1202ffd4724628df92756e0103c44e to your computer and use it in GitHub Desktop.
Save bflannery/dd1202ffd4724628df92756e0103c44e to your computer and use it in GitHub Desktop.
// 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.
function mutation(arr) {
// console.log(arr[1].toLowerCase().split(''))
return arr[1].toLowerCase()
.split('')
.every((letter) => {
// console.log(arr[0].toLowerCase().indexOf(letter));
return arr[0].toLowerCase()
.indexOf(letter) != -1;
});
}
console.log(mutation(["hello", "hey"]));
console.log(mutation(["hello", "neo"]));
console.log(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment