There is a problem with my code when pushing to the array.
The problem is with str[i]. If I replace str[i] with “A”, “T” etc. it works as I expect it to work.
Why isn’t js reading str[i] ?
function pairElement(str) {
var pairs = {
A: ["A", "T"],
T: ["T", "A"],
C: ["C", "G"],
G: ["G", "C"]
};
var paired = [];
str = str.split("");
for (i = 0; i < str.length; i++){
paired.push(Object.values(pairs.str[i]));
}
return paired;
}
pairElement("GCG");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.
Link to the challenge:
https://www.freecodecamp.org/challenges/dna-pairing