Skip to content

Instantly share code, notes, and snippets.

Created February 2, 2016 11:57
Show Gist options
  • Select an option

  • Save anonymous/51d5463bf53b413b2c6a to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/51d5463bf53b413b2c6a to your computer and use it in GitHub Desktop.
https://repl.it/Biuj/0 created by sri.pgp@gmail.com
pairs = [["A", "T"],["C","G"]]
function pair(str) {
tempArray = [];
for (j=0;j<str.length;j++){
for (i=0;i<pairs.length;i++) {
indexValue = pairs[i].indexOf(str.charAt(j));
if(indexValue==0) {
tempArray.push(pairs[i].slice());
} else if (indexValue == 1) {
pairs[i].reverse();
tempArray.push(pairs[i].slice());
}
}
}
return tempArray;
}
Native Browser JavaScript
>>> => [ [ 'A', 'T' ], [ 'C', 'G' ] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment