Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MinSomai/1f45ddc3e6d4e77bfc60ce928e9e90cd to your computer and use it in GitHub Desktop.
Save MinSomai/1f45ddc3e6d4e77bfc60ce928e9e90cd to your computer and use it in GitHub Desktop.
Intermediate Algorithm Scripting: DNA Pairing
function pairElement(str) {
let pairedDNA = [];
str.split("").forEach(strand=>{
let paired;
switch(strand){
case 'G':
paired = ['G', 'C'];
break;
case 'C':
paired = ['C', 'G'];
break;
case 'T':
paired = ['T', 'A'];
break;
case 'A':
paired = ['A', 'T'];
break;
default:
paired = [];
}
pairedDNA.push(paired);
});
return pairedDNA;
}
pairElement("GCG");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment