Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2015 05:17
Show Gist options
  • Save anonymous/bcf3fbaeb7fd4288c2e8 to your computer and use it in GitHub Desktop.
Save anonymous/bcf3fbaeb7fd4288c2e8 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/dannycoder 's solution for Bonfire: DNA Pairing
// 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