Take each character, get its pair, and return the results as a 2d array.
Base pairs are a pair of AT and CG. Match the missing element to the provided character.
Return the provided character as the first element in each array.
For example, for the input GCG, return [["G", "C"], ["C","G"], ["G", "C"]]
This is my code, can someone tell me why its not working and how to fix?
function pairElement(str) {
let newArr = [];
let hiString = str.split(" ");
for (let i = 0; i<hiString.length; i++) {
if (i = "G") {
newArr.push(["G", "C"]);
}
else if (i="C") {
newArr.push(["C", "G"]);
}
else if (i="A") {
newArr.push(["A", "T"]);
}
else if (i="T") {
newArr.push(["T", "A"]);
}
return newArr
}
}
console.log(pairElement("GCG"));