I need to cycle through strings and replace them with complementary values. Here is what I have so far:
function DNAStrand(dna){
const charMatrix = {
A: "T",
T: "A",
C: "G",
G: "C"
}
let i = 0;
let length = dna.length;
for (i; i < length; i++) {
const currentChar = dna[i].toUpperCase();
if (charMatrix[currentChar]) {
dna[i] = charMatrix[currentChar];
}
}
return dna;
}
The problem is that it enters the if
, however it doesn't seem to change the value of the character.