Although I'm not exactly sure on what you want to do, this does give the output you're expecting.
function pairElement(str) {
const dna = {
"A": "T",
"C": "G",
"T": "A",
"G": "C"
}
let arr = [];
for (const key of str){
arr.push([key, dna[key]])
}
return arr;
}
// some input tests
console.log(pairElement("GCG"));
console.log(pairElement("ACTG"));
console.log(pairElement("CCGAT"));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…