Intermediate Algorithm Scripting - DNA Pairing

Why does this not work?

Your code so far

function pairElement(str) {
  let newArr=[]
  let newArr1=[]
  for (let i=0;i<=str.length;i++)
  if(str[i]==="A"||"T") {
return newArr
  for (let j=0;j<=str.length;j++)
return newArr1



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:

What does your output look like when you run a test case?

We can work backwards from there.

It just says
[ ‘G’ ]

So you have two problems.

  1. you are pushing one letter instead of a pair of letters

  2. you are stopping after the first letter of the input

1 Like

Okay I’ll try and understand the solution

You shouldn’t copy the answer. That doesn’t help you learn how to code. That only helps you read other people’s answers.

Look at the issues one at a time.

How can you fix the fact that you are only pushing one letter instead of two?

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