-
-
Save patrickcurl/c93ea613b5a781ef938a to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/patrickcurl 's solution for Bonfire: DNA Pairing
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
| // Bonfire: DNA Pairing | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-dna-pairing | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function pair(str) { | |
| var dna = str.split(""); | |
| var pairs = []; | |
| dna.forEach(function(x){ | |
| if(x === "G"){ pairs.push(["G","C"]);} | |
| if(x === "C"){ pairs.push(["C","G"]);} | |
| if(x === "T"){ pairs.push(["T","A"]);} | |
| if(x === "A"){ pairs.push(["A","T"]);} | |
| }); | |
| return pairs; | |
| } | |
| pair("GCG"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment