DNA Pairing - code works in codepen.io but does not pass FCC tests

var arr = [];
function pairElement(str) {
  for (i=0;i<str.length;i++){
    switch (str[i]){
      case "A":
        arr.push(["A","T"]); 
        break;
        case "T":
        arr.push(["T","A"]); 
        break;
        case "C":
        arr.push(["C","G"]); 
        break;
        case "G":
        arr.push(["G","C"]); 
        break;
                  }
  }

  return arr;
}


pairElement("GCG");

Your solution won’t pass unless you move arr inside the pairElement function. Code with global variables generally won’t pass in the challenges.

That did the trick, thanks. Are we told that anywhere or is it something you figured out>

I don’t think it’s stated somewhere (correct me if I’m wrong). But lots of people ask the question when they do the same.