-
-
Save rubenribeiro/d218c22888558b1f0b77 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/dannycoder 's solution for Bonfire: 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
// Bonfire: DNA Pairing | |
// Author: @dannycoder | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-dna-pairing# | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function pair(str) { | |
var returnArr = []; | |
for(var i = 0; i < str.length; i++){ | |
switch(str.charAt(i)){ | |
case "A": | |
returnArr.push(["A", "T"]); | |
break; | |
case "T": | |
returnArr.push(["T", "A"]); | |
break; | |
case "C": | |
returnArr.push(["C", "G"]); | |
break; | |
case "G": | |
returnArr.push(["G", "C"]); | |
break; | |
default: | |
console.log("Error: Not a valid Base Pair"); | |
} | |
} | |
return returnArr; | |
} | |
pair("GCG"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment