Mysterious Organism Challenge Project (JavaScript)

It took too much time and I don’t think that this challenge worth it, I have also gave up on the middle and tried to make the best from the solution, as a non native english speaker I thought that maybe I was missing something.
Then I noticed that I was not going to the wrong direction it was just a bad challenge, your comment made me more comfortable with it, thanks.


I wanted to test different variation of a strand for each of the qAeguor but I noticed that whenever is used the variable to assign the strand attribute to each of the qAeguor when I invoked the mutation method it changed the strand/dna attribute for all the objects.

Does anybody know how to prevent this so that each object has a slight mutation of the strand variable?

Here’s some of my code so you know what I mean:

const newStrand = mockUpStrand();

const blueCritter = qAequorFactory(2, newStrand);
const redCritter = qAequorFactory(3, newStrand);


//newStrand: [
‘A’, ‘G’, ‘T’, ‘C’,
‘A’, ‘G’, ‘T’, ‘A’,
‘G’, ‘T’, ‘T’, ‘A’,
‘T’, ‘C’, ‘T’
//MUTATION of blueCritter (What I named the two species of qAeguror)
DNA bases: A,T,C,G
Random Base Removed: T
DNA bases: A,C,G
Mutated Index: 2
New Random Base: A

‘A’, ‘G’, ‘A’, ‘C’,

‘A’, ‘G’, ‘T’, ‘A’,

‘G’, ‘T’, ‘T’, ‘A’,

‘T’, ‘C’, ‘T’
//redCritter (should not be mutated)
‘A’, ‘G’, ‘A’, ‘C’,

‘A’, ‘G’, ‘T’, ‘A’,

‘G’, ‘T’, ‘T’, ‘A’,

‘T’, ‘C’, ‘T’
//check newStrand again for Comparison
‘A’, ‘G’, ‘A’, ‘C’,

‘A’, ‘G’, ‘T’, ‘A’,

‘G’, ‘T’, ‘T’, ‘A’,

‘T’, ‘C’, ‘T’

As you can see when I call the mutation method on the blueCritter it changes the DNA for the red qAeguor and also the original newStrand Variable. How do I stop this from happening so that each instance can have a mutated version of the newStrand?

Responding to the comment about the wording. I have noticed in technical instruction both on Codecademy and many text found are fraught with prepositional phrases. Any sentence that contains 1, 2 or even three ‘of’ instances requires sentence reconstruction imo. This is a constant exercise. Unrelated example;
“None of the reports about the company’s current performance compared with last year’s provided members of the board with an understanding of the reasons for the drastic decline in profits.”
Should be written: The financial reports could not explain to board members why profits declined so drastically in the past year.
This should be apply do both lesson notes and exercise questions

This is my solution

mutate() {
const index = Math.floor(Math.random() * this.dna.length);
let oldBase = this.dna[index];
let newBase = returnRandBase();
if (oldBase === newBase) {
return returnRandBase;
this.dna[index] = newBase
return this.dna;

This function you might need a loop, while loop or for loop to go through all 15 indexes. right now it only run one time with random index you got from “const index = Math.floor(Math.random() * this.dna.length);”

compareDNA(object) {
let count = 0;
for (let i = 0; i < (this.dna).length; i ++){
if (this.dna[index] === this.object[index]) {
count += 1

  • This function you are correct but they ask to return something like “specimen #1 and specimen #2 have 25% DNA in common”. So add one more step, after you have count out of for loop, calculate percent by count/dna.length. Then return the statement with percent

This was a fun challenge as I’m still getting up to speed with objects - here’s my code:

Right now both of your critters are starting with the same seed variable, and I think that means they are actually identical, which explains why they are all 3 mutating…is there a way you can get the critters to start with different DNA?

(You may have already solved this by now, but I didn’t see a reply to your comment when I scrolled up…)

Hi, here is my solution


Hey all! Here is my solution! :slight_smile:

mysterious-organism by ripeat


Here is my solution I would appreciate any feedback or advice!

Here’s my implementation of this project, including the project extensions.

my solution…

Hey everyone!
Just finished my version of this project.
Here is my solution!

Hi Javascript learners:

I share with you my solution. I guess the way I developed the mutate Method is kind of interesting. Instead of taking advantage of the already developed function to get a random DNA Base, I remove from the array of bases the mutated one and choose one at random from the reduced set.

My solution

Greetings to you all


// Returns a random DNA base const returnRandBase = () => { const dnaBases = ['A', 'T', 'C', 'G'] return dnaBases[Math.floor(Math.random() * 4)] } // Returns a random single stand of DNA containing 15 bases const mockUpStrand = () => { const newStrand = [] for (let i = 0; i < 15; i++) { newStrand.push(returnRandBase()) } return newStrand } const pAequorFactory = (num, arr) => { return { specimenNum: num, dna: arr, mutate() { const randomPosition = Math.floor(Math.random() * this.dna.length); const randomBase = this.dna[randomPosition]; loop: while (true) { let newRandBase = returnRandBase(); if (randomBase !== newRandBase) { this.dna[randomPosition] = newRandBase; break loop; } } return this.dna; }, compareDNA(pAequorObj) { const commonBases = pAequorObj.dna.filter((el, i) => el === this.dna[i]); const fraction = Math.round((commonBases.length / this.dna.length) * 100); const message = `specimen #${this.specimenNum} and specimen #${pAequorObj.specimenNum} have ${fraction}% DNA in common`; console.log(message); }, willLikelySurvive() { let count = 0; for (let i = 0; i < this.dna.length; i += 1) { if (this.dna[i] === 'C' || this.dna[i] === 'G') count += 1; } const fraction = Math.round((count / this.dna.length) * 100); return fraction >= 60 ? true : false; }, complementStrand() { const complementDNA = Array.from(this.dna); complementDNA.forEach((el, i, arr) => { switch(el) { case 'A': arr[i] = 'T'; break; case 'T': arr[i] = 'A'; break; case 'C': arr[i] = 'G'; break; case 'G': arr[i] = 'C'; break; } }); return complementDNA; } } }; const pAequorInstances = []; for (let i = 1; i <= 30; i += 1) { const newInstance = pAequorFactory(i, mockUpStrand()); if (newInstance.willLikelySurvive()) { pAequorInstances.push(newInstance); } } console.log(pAequorInstances);

tHis iS wahT cOdEcADemY’s sOlUtIOn code returns lmaooo FOH

working thru my 2nd 6th month long course and this is just so commonplace for some of these codecademy devs. Its as if only a fraction of the content is vetted. Very frustrating.

Hi everyone, For this task you can find my solution on github with this link :

Please feel free to leave a comment, thanks!
Enjoy :wink: