Intermediate Algorithm Scripting - DNA Pairing

Tell us what’s happening:
I am trying to solve the algorithm test on DNA pairing. It only returns for the first element only. Kindly help to understand where I am messing. I will greatly appreciate.

Your code so far

function pairElement(str) {
  let arr = [];
  let splitStr = str.split('');
  for(let i = 0; i < splitStr.length; i++){
    if(splitStr[i] === 'G'){
    arr.push(['G', 'C']);
  } else if(splitStr[i] === 'C'){
    arr.push(['C', 'G']);
  }else if(splitStr[i] === 'A'){
    arr.push(['A', 'T']);
  } else if(splitStr[i] === 'T'){
    arr.push(['T', 'A']);
  return arr;


Your browser information:

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

Challenge: Intermediate Algorithm Scripting - DNA Pairing

Link to the challenge:

Recirculate the outer return

1 Like

Thanks. It worked perfectly.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.