Tell us what’s happening:
The test cases aren’t approved inspite of getting identical output to what is required. Attaching an image for reference.
Your code so far
var completedSequence = [];
function pairElement(str) {
var givenSequence = str.split('');
for ( var i = 0; i < givenSequence.length; i++ ){
var tempArray = [];
tempArray.push(givenSequence[i]);
if ( basePairs[0].indexOf(givenSequence[i]) >= 0 ) {
if ( basePairs[0].indexOf(givenSequence[i]) == 0 ) {
tempArray.push(basePairs[0][1]);
completedSequence.push(tempArray);
} else {
tempArray.push(basePairs[0][0]);
completedSequence.push(tempArray);
}
} else {
if ( basePairs[1].indexOf(givenSequence[i]) == 0 ) {
tempArray.push(basePairs[1][1]);
completedSequence.push(tempArray);
} else {
tempArray.push(basePairs[1][0]);
completedSequence.push(tempArray);
}
}
}
return completedSequence;
}
pairElement("ATCGA");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/dna-pairing