loading...

DNA paring free code camp intermediate algorithm

95freedom95 profile image Oscar Hernandez ・1 min read

function pairElement(str) {
var a = /[A-Z]/gi;
var b = []; var arr =[];
var x =[]; var args =[];
for(let i=0; i<str.length;i++){
b = str.match(a);
if(b[i] === "A"){
arr = b[i].concat("T");
}if(b[i] === "T"){
arr = b[i].concat("A");
}if(b[i] === "C"){
arr = b[i].concat("G");
}else if(b[i] === "G"){
arr = b[i].concat("C");
}
var x = arr.split("");
args.push(x)
console.log(args);

}

return args;
}
pairElement("TGCGAT");
/pairElement("ATCGA") should return [["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]].
Passed
pairElement("TTGAG") should return [["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]].
Passed
pairElement("CTCTA") should return [["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]].
/

Posted on by:

95freedom95 profile

Oscar Hernandez

@95freedom95

I AM oriented to learn new things, student at Free code camp.

Discussion

markdown guide
 

It's unclear from your post what this is about. I would recommend including more details, or at least a link to whatever problem you're solving.