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”]]
The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array.
A-T,T-A,C-G,G-C配对;
返回二维数组[[原先字符,配对字符],[]]
function pairElement(str) {
var o = {
'G': 'C',
'C': 'G',
'A': 'T',
'T': 'A',
};
return str.split('').map((cur) => {
return [cur, o[cur]];
});
}
pairElement("GCG");