Intermediate Algorithm Scripting: DNA Pairing - advice?

Tell us what’s happening:

Hi there, I believe this solution is correct. I checked that on the console and it works fine. It does not seem to satisfy fCC though.

Any advice?

Thanks,
Tower

Your code so far


function pairElement(str) {

const pairsObj = {
  A: "T",
  T: "A",
  C: "G",
  G: "C"
}

let res = [];

for(let i = 0; i < str.length; i++) {
  res.push( [ [ str[i], pairsObj[str[i]] ] ] );  
}

return res;

}

pairElement("ATCGA");

Your browser information:

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

Challenge: DNA Pairing

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing

Read this question again you have to return 2d array but you returning 3d array.

1 Like

OMG - you are right. Not even sure why I randomly added those additional pairs of square brackets.
Thanks for your help.