Skip to content

Instantly share code, notes, and snippets.

@samkahchiin
Created March 27, 2016 10:35
Show Gist options
  • Save samkahchiin/ce8e40e0c3b3fde7ba78 to your computer and use it in GitHub Desktop.
Save samkahchiin/ce8e40e0c3b3fde7ba78 to your computer and use it in GitHub Desktop.
freecodecamp : DNA Pairing
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