Created
March 27, 2016 10:35
-
-
Save samkahchiin/ce8e40e0c3b3fde7ba78 to your computer and use it in GitHub Desktop.
freecodecamp : DNA Pairing
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
function pair(str) { | |
var dna_pair = { "A" : "T", | |
"T" : "A", | |
"C" : "G", | |
"G" : "C"}; | |
str = str.split(""); | |
for(var i = 0; i < str.length; i++){ | |
var arr = [str[i]]; | |
for(var key in dna_pair){ | |
if(key === str[i]){ | |
arr.push(dna_pair[key]); | |
} | |
} | |
str[i] = arr; | |
} | |
return str; | |
} | |
pair("GCG"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment