DNA Pairing coding algo critique

I feel as if I’m close to a solution, but for some reason… There’s something I don’t understand that’s making this more difficult than it should be. Maybe, I need to go back and get a better understanding of some other principles, or … I dunno, just not sure what exactly I’m missing here. What concept am I struggling to grasp that’s making this difficult?

function pairElement(str) {

let regexA = /A+/;

let regexT = /T+/;

let regexC = /C+/;

let regexG = /G+/;

let strArr = str.split(“”);

let newArr = ;

//console.log(newArr);

//console.log(strArr);

//console.log(str.replace(regexC, “[C, G]”))

str.replace(regexC, “[C, G]”)

str.replace(regexG, “[G, C]”)

str.replace(regexT, “[T, A]”)

str.replace(regexA, “[A, T]”)

// --------------------------------

//replacing function!

// --------------------------

newArr = strArr.map(x => {

if(x === “C”) {

x.replace(regexC, “[C, G]”)

} else if (x === “G”) {

x.replace(regexG, “[G, C]”)

} else if (x === “T”) {

x.replace(regexT, “[T, A]”)

} else if (x === “A”) {

x.replace(regexA, “[A, T]”)

}

console.log(newArr);

return x

})

};

pairElement(“GCG”);

nvm figured it out…

no need for any answered for anyone…

but thanks anyways…

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.