# DNA pairing. Help pls code isn't working

``````function pairElement(str) {

let arr = str.split("")

var newArray = [];

var firstPair = ["A", "T"];

var secondPair = ["G", "C"];

for (var i = 0; i < arr.length; i++) {

newArray.push(arr.slice(i, i + 1))

};

for (var i = 0; i < newArray.length; i++) {

for (var j = 0; j < newArray[i].length; j++) {

if(firstPair.indexOf(newArray[j]) != -1 && newArray[j] == firstPair) {

newArray[i].push(firstPair.slice(1));

}

else if(firstPair.indexOf(newArray[i][j]) != -1 && newArray[i][j] == firstPair) {

newArray[i].push(firstPair.slice(0, 1));

}

else if(secondPair.indexOf(newArray[i][j]) != -1 && newArray[i][j] == secondPair) {

newArray[i].push(secondPair.slice(1));

}

else if(secondPair.indexOf(newArray[i][j]) != -1 && newArray[i][j] == secondPair) {

newArray[i].push(secondPair.slice(0, 1));

}

}

}

return newArray;

}

pairElement("GCG");
``````

We am going to need more information, as we have no clue what this code is supposed to be doing and how it’s failing to meet your expectations.

Here is the guideline

The DNA strand is missing the pairing element. 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”]]

The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array.