Forked from anonymous/bonfire-mutations?solution=function%20mutation(arr)%20%7B%0A%20%20list%20%3D%20arr%5B1%5D.toLowerCase().split(%22%22)%3B%0A%20%20for(i%3D0%3Bi%3Clist.length%3Bi%2B%2B)%7B%0A%20%20%20%20if(arr%5B0%5D.toLowerCase().indexOf(list%5Bi%5D)%3C0)%20%7B%0A%20
Created
November 30, 2015 10:08
-
-
Save srkama/aa178709ff02d42e2586 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/srkama 's solution for Bonfire: Mutations
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
| // Bonfire: Mutations | |
| // Author: @srkama | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations?solution=function%20mutation(arr)%20%7B%0A%20%20list%20%3D%20arr%5B1%5D.toLowerCase().split(%22%22)%3B%0A%20%20for(i%3D0%3Bi%3Clist.length%3Bi%2B%2B)%7B%0A%20%20%20%20if(arr%5B0%5D.toLowerCase().indexOf(list%5Bi%5D)%3C0)%20%7B%0A%20%20%20%20%20%20return%20false%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20true%3B%0A%7D%0A%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) { | |
| list = arr[1].toLowerCase().split(""); | |
| for(i=0;i<list.length;i++){ | |
| if(arr[0].toLowerCase().indexOf(list[i])<0) { | |
| 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