Mysterious Organism Challenge Project (JavaScript)


Another one.

Has anyone done the last step for extra practice?

It says " * Use the .compareDNA() to find the two most related instances of pAequor."

There is got to be a simple way that I’m overlooking, but looking through others codes, I cant find any that tackled the issue, or its so simple that I glazed over it thinking it was something else.

Any input is appreciated!


------- EDIT --------

I found a solution. but I’m still sure there is an better way.

I did this:

// Takes in nested arrays of samples and returns the first set of
// most related samples
const getTwoBest = (nestedArrays) => {
let strings = ;
let percents = ;
let highestPercent = 0;
for (let i = 0; i < nestedArrays.length; i++) {
for (let v = 0; v < nestedArrays.length; v++) {
if (i !== v){
strings.forEach(string => percents.push(string.substr(-17, 2)));
highestPercent = Math.max(…percents);
let stringPercent = ${highestPercent}%;

for (let j = 0; j < strings.length; j++) {
if (stringPercent === strings[j].substr(-17, 3)) {
return strings[j]

If you want to see how it in its entirety:

Hello everyone,

This is my solution, I would be more than happy if you can give it a few minutes and share your ideas with me.


I don’t even understand what I’m to do in the mutate method of the returning class, I’m stuck. can someone please explain better.

Hi there, here is my solution! This one took some time, but brought a ton of satisfaction upon completion. Can feel myself becoming smarter ahahah


Would like to hear some feedback of criticism :pray:

Hey there, I’ll give it a try…

You’re .mutate( ) should randomly pick one of the elements in the dna array of this returned objects’ dna, then change that dna[randomIndex] to a diff element of the 4 bases (you could do this by comparing the randomly selected element to another element using the returnRandBase( ) as a helper function, for instance). I hope this helps, and that I didn’t muck it up for you further!

1 Like


I think you mean this method, I added some comments, explaining each line:

// generate a random base number (a random index in the DNA array), we are going to mutate that in later steps
const randomBaseNum = Math.floor(Math.random() * this.dna.length);
//we need to replace that randomly selected base, with a different base; we have 4 base in total so we filter out the randomly selected base from our list of bases (because we want it to be changed to something different)
const dnaBases = [‘A’, ‘T’, ‘C’, ‘G’].filter(base => base !== this.dna[randomBaseNum]);
//now, we replace the randomly selected base in our DNA, with a randomly selected base in our filtered list.
this.dna[randomBaseNum] = dnaBases[Math.floor(Math.random() * 3)] ;

Please Can someone kindly explain to me Where this code for compareDNA is giving me this result?


      let count = 0;
      for (const n of this.dna){
        if (n === otherSpecimen[this.dna.indexOf(n)]){
      let similaritiesPercentage = ((count / this.dna.length) * 100).toFixed(2);
      console.log(`Specimen #${this.specieNum} and #${otherSpecimen.specieNum} have ${similaritiesPercentage}% DNA in common.`);


let spec1Arr = mockUpStrand();
let spec2Arr = mockUpStrand()
let specimen1 = pAequorFactory(1, spec1Arr);
let specimen2 = pAequorFactory(2, spec2Arr);


Specimen #1 and #undefined have 13.33% DNA in common.

Why the undefined ???

It shows you ‘undefined’ because when you call compareDNA() function you put ‘specimen2.dna’ instead of just ‘specimen2’. And as a result your current function actually looks for ‘specimen2.dna.specieNum’ that doesn’t exist.
Try editing the last line:

Here´s my solution:

This one was tough mainly because I was stuck at the point when my function that was designed to find the most related instances perceived the number 7 as greater than 63. The problem was in the .toFixed() method as it returns a string, not a number, and I had to use parseInt() to resolve that…
Here is my final code for this challenge.

Thanks for sending this over Ruvez.
I will try that right away.

I just did and it worked out.
Thanks, lot, Ruvez. Hope we can communicate. if you are down with that then please let me know so we can share contact.

1 Like

Cool! I’m glad it worked out for your code!) Yes, sure, I’m actually looking for somebody to try pair programming for the next challenge project or just for some interesting tasks on JS. I believe it can strongly improve the skills of both practitioners.
So, send me a PM if you are interested)

My solution: Codecademy export · GitHub

Hi Ruvez, I have sent you a Message. Kindly look it up.

Your Solution is quite lengthy and looks interesting, I will take time to study it later. Welcome to the community by the way.

Hi, everybody, I share my code for all want to see it, thanks

GitHub - meletioskorres/mystery-organism-starter my solution