Intermediate Algorithm Scripting - DNA Pairing

why does this not work

function pairElement(str) {

  let farr=[];
  let strarr=[[2],[1]];
  strarr=str.slice(str);

  strarr.forEach(element => farr.push(element));
    
  


  console.log(farr);
  return str;
}

pairElement("GCG");

everywhere i look i see this syntax for foreach

i get an error strarr.forEach is not a function

nevermind sorry , can someone tell me how to delete thread?

So what is the value of strarr after you do this?

strarr=str.slice(str)

There’s nothing wrong with the forEach syntax, but the forEach function works on arrays.

So the above makes no sense anyway: you have written (using the example input at the bottom):

strarr = "GCG".slice("GCG")

What you do think this is going to do?

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