Intermediate Algorithm Scripting: DNA Pairing -- SO Close!

Can anyone help? I’ve almost solved this problem. I’ve gotten an array with the appropriate output, but I’m having trouble converting that array into a multidimensional array. Comments left in the code below. Any help is appreciated.



function pairElement(str) {

 str = str.split("");
for (let i =0; i < str.length; i++) {
  if (str[i] === 'G') {
    str[i] = "GC";
  }
  else if (str[i] === 'C') {
    str[i] = "CG"
  }
  else if (str[i] === 'T') {
    str[i] = 'TA'
  }
  else {
    str[i] = "AT"
  }
}
console.log(str); // Prints out [ 'TA', 'TA', 'GC', 'AT', 'GC' ]
for (let j = 0; j < str.length; j++)
{
  let result = [];
  result.push(str.slice(0, j+1));
  console.log("hello"); // I added this line to test whether
this code chunk was being looped through. For whatever reason, 
my for loop's "looping" doesn't seem to be working.
This is clearly demonstrated by hello only being
printed once to the console, as well as only the
first element of the str array. Any ideas?
  return result
}

}

pairElement("TTGAG")

Yeah, return result being inside your for loop makes it exit the entire function after the first iteration of the loop