Skip to content

Instantly share code, notes, and snippets.

  • Save sawant/d3dd150c48cc098acf28 to your computer and use it in GitHub Desktop.
Save sawant/d3dd150c48cc098acf28 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/sawant 's solution for Bonfire: Mutations
// Bonfire: Mutations
// Author: @sawant
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations?solution=function%20mutation(arr)%20%7B%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20arr%5B1%5D.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20if%20(%20arr%5B0%5D.toLowerCase().indexOf(%20arr%5B1%5D%5Bi%5D.toLowerCase()%20)%20%3D%3D%3D%20-1%20)%20return%20false%3B%0A%20%20%7D%0A%20%20%0A%20%20return%20true%3B%0A%7D%0A%0Amutation(%5B%22hello%22%2C%20%22hey%22%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
for (var i = 0; i < arr[1].length; i++) {
if ( arr[0].toLowerCase().indexOf( arr[1][i].toLowerCase() ) === -1 ) 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