DNA Pairing: correct in console, but isn't passing tests?

DNA Pairing: correct in console, but isn't passing tests?
0

#1

Can you help me understand why my code is giving the correct output to the console but not in fCC?

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

  str.split("").map((letter) => {
    switch (letter) {
      case "A": 
        gene.push(["A, T"]);
        break;
      case "T": 
        gene.push(["T, A"]);
        break;
      case "G": 
        gene.push(["G, C"]);
        break;
      case "C": 
        gene.push(["C, G"]);
        break;
    }
  });
  return gene;
}

console.log(pairElement("GCG"));

thanks for any and all thoughts!


#2

It is not correct in the console. You are supposed to be pushing arrays with two elements each time. Instead you are pushing single string elements which look like “C, G”.

The first test case should look like:

[ [ 'A', 'T' ], [ 'T', 'A' ], [ 'C', 'G' ], [ 'G', 'C' ], [ 'A', 'T' ] ]

but your solution returns:

[ [ 'A, T' ], [ 'T, A' ], [ 'C, G' ], [ 'G, C' ], [ 'A, T' ] ]

#3

:woman_facepalming: once again you come to the rescue. thanks, Randell :slight_smile: