Intermediate Algorithm Scripting: DNA Pairing
function pairElement(str) {
//define a map object with all pair possibilities
var map = {T:'A', A:'T', G:'C', C:'G'};
//split str into a char Array
strArr = str.split('');
//replace each Array item with a 2d Array using map
for (var i=0;i<strArr.length;i++){
strArr[i]=[strArr[i], map[strArr[i]]];
}
return strArr;
}
// test here
pairElement("GCG");