The following should take the input and create a 2D array of letter pairs - [["A", "T"], ["T", "A"], ["C","G"]] but it is currently only returning [["A", "T"], ["T", "A"]], which makes me suspect there is something wrong with my loop logic.
function pair(str) {
var paired = [];
var str = str.split("");
for (i=0; i<str.length; i++) {
var newStr = str.splice(0,1);
if (newStr[0] === "A") {
newStr.push("T");
}
if (newStr[0] === "T") {
newStr.push("A");
}
if (newStr[0] === "C") {
newStr.push("G")
}
if (newStr[0] === "G") {
newStr.push("C")
}
paired.push(newStr);
}
return paired;
}
pair("ATC");