Skip to content

Instantly share code, notes, and snippets.

@patrickcurl
Forked from anonymous/bonfire-dna-pairing.js
Created December 9, 2015 11:33
Show Gist options
  • Select an option

  • Save patrickcurl/c93ea613b5a781ef938a to your computer and use it in GitHub Desktop.

Select an option

Save patrickcurl/c93ea613b5a781ef938a to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/patrickcurl 's solution for Bonfire: DNA Pairing
// 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