Mysterious Organism Challenge Project (JavaScript)

Congratulations on completing your project!

Compare your project to our solution code and share your project below! Your solution might not look exactly like ours, and that’s okay! The most important thing right now is to get your code working as it should (you can always refactor more later). There are multiple ways to complete these projects and you should exercise your creative abilities in doing so.

This is a safe space for you to ask questions about any sample solution code and share your work with others! Simply reply to this thread to get the conversation started. Feedback is a vital component in getting better with coding and all ability levels are welcome here, so don’t be shy!

About community guidelines: This is a supportive and kind community of people learning and developing their skills. All comments here are expected to keep to our community guidelines

How do I share my own solutions?

  • If you completed the project off-platform, you can upload your project to your own GitHub and share the public link on the relevant project topic.
  • If you completed the project in the Codecademy learning environment, use the share code link at the bottom of your code editor to create a gist, and then share that link here.

Do I really need to get set up on GitHub?
Yes! Both of these sharing methods require you to get set up on GitHub, and trust us, it’s worth your time. Here’s why:

  1. Once you have your project in GitHub, you’ll be able to share proof of your work with potential employers, and link out to it on your CV.
  2. It’s a great opportunity to get your feet wet using a development tool that tech workers use on the job, every day.

Not sure how to get started? We’ve got you covered - read this article for the easiest way to get set up on GitHub.

Best practices for asking questions about the sample solution

  • Be specific! Reference exact line numbers and syntax so others are able to identify the area of the code you have questions about.

Hi anna, thanks for the solution.

I noticed the solution for Question 4: .mutate was as such.

      this.dna[randIndex] = newBase;

After experimenting, I realized this doesn’t seem to work. this.dna remains unchanged, and doesn’t mutate at the specified index.

How do I replace a character at a particular index in JavaScript?

I’m not sure whether I understood the problem correctly too.

Hey Mr. WebJumper, I had a similar symptom to some things in my code. In the end I realized that for some reason if you’re checking its functionality with console.log() within the method, it seems to log things after the changes have been made. so I’d have a console.log(this.dna) before the .splice() and then an exact same one afterwards. When in reality, the code was working fine and was indeed changing the bases properly.

NOTE: My blunder was also doing Math.random instead of Math.random() making randIndex = NaN

Try doing this on your browser console (open tab > right click anywhere > Inspect Element > change to Console), enter the object with its methods, create animal1, log its DNA strand, mutate it, then log its DNA again. I’ll leave my working code here if you want to compare!

Short version: the code you mentioned should work if the rest is done properly.

// Returns a random DNA base
const returnRandBase = () => {
  const dnaBases = ['A', 'T', 'C', 'G'];
  return dnaBases[Math.floor(Math.random() * 4)];

// Returns a random single strand of DNA containing 15 bases
const mockUpStrand = () => {
  const newStrand = [];
  for (let i = 0; i < 15; i++) {
  return newStrand;

const pAequorFactory = (num, bases) => {
  return {
    specimenNum: num,
    dna: bases,
    mutate() {
      // random Loc on DNA
      let i = Math.floor(Math.random() * this.dna.length);

      // target base's letter
      let oldBase = this.dna[i];

      // Swapping out (mutating) base on DNA
      let altBases = ['A', 'T', 'C', 'G'];
      altBases.splice(altBases.indexOf(oldBase), 1); // find and remove target base
      let mutatedBase = altBases[Math.floor(Math.random() * 3)]; // take one of 3 altBases
    //   console.log(`Changed ${oldBase} to ${mutatedBase} on number ${i}`);
      return this.dna.splice(i, 1, mutatedBase);   
    compareDNA(otherPAqeour) {
      let count = 0;
      for (let i = 0; i < this.dna.length; i++) {
        if (this.dna[i] == otherPAqeour.dna[i]) {
          count += 1;
      // console.log(`Specimen #${this.specimenNum} has ${count * 100/this.dna.length}% DNA bases in common with #${otherPAqeour.specimenNum}.`)
    willLikelySurvive() {
      const cAndG = this.dna.filter(letter => letter === 'C' || letter === 'G');

      if (cAndG.length/this.dna.length > 0.6) {
        return true;
      } else {
        return false;

  // 30 instances
let sample = [];
let i = 0;
while (sample.length < 30) {
  let temp = pAequorFactory(i, mockUpStrand());
  if (temp.willLikelySurvive() == true) {
    i += 1

Hey guys! So i have been sitting and staring at t his portion of the problem now for a while. I have tried both the provided solution code and other forum members’ solutions to no avail. This is the code that I have come up with to try and solve the mutation part of the problem but keep getting the same strand of DNA printed to console in both cases. It’s as if the mutation method never runs.

I have tried to log the index created under i as well as the randomBase that i selects but sometimes I get differing values. I.e. my index value will be 4 but the randomBase that is logged to the console is a base in the DNA that does not equate to the element at said index.

If anyone can offer assistance I would love you forever and ever. My biggest hurdle in this program is having assistance when I get stumped for an hour plus.

Zach V

I’m also having the same problem, I’ve got the code, but it’s also printing out function: function name, instead of working. I feel like there is very simple solution to this that I’m missing, if anyone would point this, I’d be very grateful.

Never mind, found it. When you call a function inside an object, you have to be more specific and specify the method. function(param1, param2).method

This is my solution. Any advice? It seems that the function mutate isn’t useful for the final result of batching 30 surviving specimen (or am I missign something)?

Thank you for your help

My solution with complementary strand.
It would be easier to get the two most similar specimen if compareDNA wouldnt return a string but the percentage of similarity.

Right now you don’t enter the if statement when compareBase and randomBase are the same and you are returning the unaltered this._dna . You need to figure out a way to keep calling returnRandBase until compareBase and randomBase are not equal, then return this._dna

Hi folks. I enjoyed this challenge. Here is my solution.

Wasn’t sure if we were expected to change .compareDNA() to return the percentage but that seemed the best way to find the most related instances of pAeqour


Hi everyone,

This is my solution:

Happy coding <3

this was a tough one for me, I kept forgetting to call the factory method correctly with the specimen number and a dna strand. So this is what I came up with I didn’t do the extra stuff yet

First, I’d like to thank you all for the precious tips I got reading your programs/posts.

I have just finished this challenge and this is my code. Anyone willing to share tips, please, go on :blush:.

1 Like

This project was a really challenging one, but you know what: I have a blast and so much satisfaction when I finished. I would appreciate all the feedback posible, because I know it can do it better.

Here’s my attempt at this. Everything seems to be working. I intend on adding the extensions soon. Would love to hear people’s thoughts on what could be better.

Updated with extensions.

Hi Anna,

If I am asking this question in the wrong forum please redirect me to the right place.

I’ve spent a while trying to figure out how to open and view the solution you posted. I’ve been learning about GitHub and have downloaded Node.js as it instructs (you might notice I’m completely new to this). However I can’t open the .zip file that the link downloads to my computer (Windows 10).

If I open the file in VS Code it tells me that it doesn’t recognize the format.

Is there a simple step that I am missing here?


Great solutions guys, interesting to see the different coding patterns, here is a link to mine:

Hey there,
here is my version. That was fun and I really appreciate the way you guys from codecademy wrap those challanges: :octopus: :octopus: :octopus: