DNA Pairing tell me whats wrong with my code

DNA Pairing tell me whats wrong with my code
0

#1

Tell us what’s happening:
what is wrong with my code

Your code so far


function pairElement(str) {
  str = str.toUpperCase();
  str = str.split("");
  var placeHolderArray = [];
  for (var i = 0 ; i<str.length; i++){
    if(str[i]=="A"){
      placeHolderArray.push(["A", "T"]);

    }else if (str[i]=="T"){
      placeHolderArray.push(["T", "A"]);
    }else if (str[i]=="C"){
      placeHolderArray.push(["C", "G"]);
  }else if (str[i]=="G"){
      placeHolderArray.push(["G", "C"]);}
  return placeHolderArray;
}
}
pairElement("GCG");

Your browser information:

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

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


#2

You are so close. The logic is sound, it’s a syntax error.

Check your curly brackets :grinning:


#3

where???bro


#4

Why is your return statement where it is?


#5

Make sure to check your curly brackets! Your solution looks very similar to mine, here is how i went about it!

[spoiler]function pairElement(str) {
var newArr = [];

str = str.split("");
for (var i = 0; i < str.length; i++) {
var gc = [“C”];
var cg = [“G”];
var at = [“T”];
var ta = [“A”];

if (str[i] === "G") {
  gc.unshift(str[i]);
  newArr.push(gc);
} 
if (str[i] === "C") {
  cg.unshift(str[i]);
  newArr.push(cg);
}
if (str[i] === "A") {
  at.unshift(str[i]);
  newArr.push(at);
}
if (str[i] === "T") {
  ta.unshift(str[i]);
  newArr.push(ta);
}
}

return newArr;
}

console.log(pairElement(“GCG”));[/spoiler]