Created
November 25, 2015 15:32
-
-
Save codebubb/6b4451dbc210ba1d132e to your computer and use it in GitHub Desktop.
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
// Bonfire: DNA Pairing | |
// Author: @codebubb | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-dna-pairing?solution=function%20pair(str)%20%7B%0A%20%20return%20str.split(%27%27).map(function(e)%7B%0A%20%20%20%20switch(e)%7B%0A%20%20%20%20%20%20%20case%20%22C%22%3A%20return%20%5B%22C%22%2C%20%22G%22%5D%3B%0A%20%20%20%20%20%20%20case%20%22G%22%3A%20return%20%5B%22G%22%2C%20%22C%22%5D%3B%0A%20%20%20%20%20%20%20case%20%22A%22%3A%20return%20%5B%22A%22%20%2C%22T%22%5D%3B%0A%20%20%20%20%20%20%20case%20%22T%22%3A%20return%20%5B%22T%22%2C%20%22A%22%5D%3B%0A%20%20%20%20%7D%0A%20%20%7D)%3B%20%20%0A%7D%0A%0Apair(%22GCG%22)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
// Comments: | |
// Once i'd figured out what this was asking it wasn't so bad. Enabled to remove some lines by using .map to replace the str | |
function pair(str) { | |
return str.split('').map(function(e){ | |
switch(e){ | |
case "C": return ["C", "G"]; | |
case "G": return ["G", "C"]; | |
case "A": return ["A" ,"T"]; | |
case "T": return ["T", "A"]; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment