Created
March 20, 2018 19:35
-
-
Save nickihastings/f8114d4edbd5ea96b3b7bfa0330565fe to your computer and use it in GitHub Desktop.
The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array. Base pairs are a pair of AT and CG. Match the missing element to the provided character. Return the provided character as the first element in each array. For example, for the input GCG, return [["G", "C"], ["C","G"],["G", "C"]…
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
function pairElement(str) { | |
str = str.split(""); | |
var pairs = []; | |
for(var i = 0; i < str.length; i++){ | |
switch (str[i]) { | |
case "C": | |
pairs.push(["C", "G"]); | |
break; | |
case "G": | |
pairs.push(["G", "C"]); | |
break; | |
case "A": | |
pairs.push(["A","T"]); | |
break; | |
case "T": | |
pairs.push(["T", "A"]); | |
break; | |
} | |
} | |
return pairs; | |
} | |
pairElement("GCG"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment