Intermediate Algorithm Scripting: DNA Pairing

Intermediate Algorithm Scripting: DNA Pairing
0

#1

Tell Us What’s Happening So Far:
I’ve coded a simple for…loop with if statements to handle the DNA pairing problem:

Your Code So Far:

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

Even though the output appears correct, FCC wont accept this solution. Can anyone tell me what I’m doing wrong?


#2

What do the failing tests say?


#3

Sorry, I’m using codepen.io because I believe it’s console.log() function is more flexable and I didn’t copy the code over to FCC correctly. It passed. :grimacing: