Why would this code fail tests?

Edit: Please ignore. I found the reason why is because I was not returning mainArray.

Tell us what’s happening:
I’m completing this challenge and as I show the result of ‘mainArray’ in console, it appears to be correct. Yet the tests still fail. Why would the tests fail?

Your code so far

function pairElement(str) {
let mainArray = [];

for (let i = 0; i < str.length; i++) {
  switch (str[i]) {
    case 'G':
      mainArray.push(['G', 'C']);
    case 'C':
      mainArray.push(['C', 'G']);
    case 'T':
      mainArray.push(['T', 'A']);
    case 'A':
      mainArray.push(['A', 'T']);
return str;


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0.

Challenge: DNA Pairing

Link to the challenge:

Make sure you are returning the correct thing from the pairElement function.

1 Like