Mysterious Organism Part 9

I’m working on part 9 of this project: Create a .complementStrand() method to the factory function’s object that returns the complementary DNA strand. The rules are that 'A' s match with 'T' s and vice versa. Also, 'C' s match with 'G' s and vice versa. (Check the hint for more details).

My complementStrand when logged to the console is showing that only one item is being added to my obj1 array. I’m confused because I thought the loop would iterate by 1 (the i) and 15 items would be added before reaching i<15. It prints the correct item to the array, just 15 indexes are not being made.

Thanks for the help everyone! :slight_smile:

use of console.log isn’t limited to final results, you could for make the code describe what it’s doing as it’s doing it which you can use to narrow down where it goes wrong

Never mind, I figured out it was because I was returning the new array inside of the for loop, not outside of it!

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