Created
November 13, 2017 01:14
-
-
Save femontanha/0fad4219ed6edb1ee4c53b1552c32f7c to your computer and use it in GitHub Desktop.
DNAStrand
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
function DNAStrand(dna) { | |
return dna.replace(/./g, function(c) { | |
return DNAStrand.pairs[c] | |
}) | |
} | |
// OR | |
function DNAStrand(dna) { | |
return dna.split('').map((item) => pairs[item]).join('') | |
} | |
DNAStrand.pairs = { | |
A: 'T', | |
T: 'A', | |
C: 'G', | |
} | |
// e.g | |
DNAStrand('AAAAA') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment