DNA Pairing Help Please?

DNA Pairing Help Please?
0

#1

The following is my code. For some reason the loop at the end is not doing what I want it to do (split the strings into arrays with characters). Can someone please tell me why?

function pairElement(str) {
var stringArray = str.split("");

for (var i = 0; i < stringArray.length; i++) {
if (stringArray[i] === “A”) {
stringArray[i] += “T”;
}
else if (stringArray[i] === “T”) {
stringArray[i] += “A”;
}
else if (stringArray[i] === “C”) {
stringArray[i] += “G”;
}
else if (stringArray[i] === “G”) {
stringArray[i] += “C”;
}

}
for (var j = 0; j < stringArray.length; j++) {
stringArray[j].split("");
}

return stringArray;
}


#2

First, try to declare “some empty array”, and then:
Instead of:
stringArray[i] += "something";try with:someEmptyArray.push([stringArray[i], "something"]);At the end:``return someEmptyArray;
`


#3

Hi, you should see my alternative solution.