DNA Pairing return problem

Tell us what’s happening:
I am getting the correct solution when I console.log but when I change that to a return statement it no longer works. Can anyone help me understand why? Thanks.

Your code so far


function pairElement(str) {
 let test = str.split("");
 let sample = []  
 for (let i in test){
   sample.push(test[i].split())
 }
 arrayConst(sample);
 function arrayConst(array){
   for (let i in array){
   if (array[i][0] === 'G') {
     array[i].push('C')
   } else if (array[i][0] === 'C') {
     array[i].push('G')
   } else if (array[i][0] === 'A') {
     array[i].push('T')
   } else if(array[i][0] === 'T') {
     array[i].push('A')
   } 
   }
console.log(array);
return array;    
}
}
pairElement("ATCGA");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.

Challenge: DNA Pairing

Link to the challenge:

Your arrayConst function creates the desired final array, when you call arrayConst(sample). The problem is you never return the result of calling arrayConst(sample) back to the original call to the function pairElement. When a function does not explicitly return a value, the value undefined is returned by default.

Thanks. My brain was locked up on a simple issue. I assigned my function call to a variable and returned it at the end. Thanks again.