Mysterious Organism

Hello,
I have spend a day to solve the Mysterious Organism challange.
At the moment all functions are working without error. I have missed only the final point. I have to generate 30 DNA sequences.
I have the following code:

'use-strict';
// 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 = (specimenNum, bases) => {
  return {
    specimenNum: specimenNum,
    dna: bases, //mockUpStrand()
    mutate() {
      let i = Math.floor(Math.random() * this.dna.length);
      let oldBase = this.dna[i];
      let altBases = ['A', 'T', 'C', 'G'];
      altBases.splice(altBases.indexOf(oldBase), 1);
      let mutatedBase = altBases[Math.floor(Math.random() * 3)];
      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) {
          count += 1;
        }
        console.log(
          `Specimen #${this.specimenNum} has ${
            (count * 100) / this.dna.length
          }% DNA bases in common with #${otherPAqeour.specimenNum}.`
        );
      }
    },
    willLikelySurvive() {
      count = 0;
      for (let i = 0; i < pAequorFactory.length; i++) {
        if (pAequorFactory[i] === 'C' || pAequorFactory[i] === 'G') {
          count += 1;
        }
        let countOfString = this.dna.length;
        let isItGoingToSurvive = count / countOfString;
        if (isItGoingToSurvive >= 0.6) {
          return true;
        } else {
          return false;
        }
      }
    },
  };
};

console.log(pAequorFactory(1));

I get a return in the form of:


I get the name of the function but not the values that they are supposed to execute. I would consider this as working code because I do not have error, but how do I actually get the results from the function into the object?
I can change the:

const pAequorFactory = (specimenNum, bases) =>

to:

const pAequorFactory = (specimenNum, bases = mockUpStrand()) =>

this will generate an array of DNA, however still the willLikelySurvive function provide only name and not an actual value.

Hey tsetsko,

I’m also trying to work on this project right now and trying to remember how to use these functions.

I too ran into a similar problem regarding logging the methods. But from going back to the Robot Factory exercise, in order to use your function you need to declare a new constant. The value of that constant needs to call pAequorFactory function which should have something for the two arguments you created.

For example:

const  organism = pAequorFactory(1, dna)

And then if you need to use the properties and methods you do something like:

console.log(organism.dna)
organism.mutate()
organism.compareDNA(otherPAequor)

if you just do console.log(pAequorFactory(1)) all it’s going to do is list everything you have in the object. If you passed arguments it will just list them:

{specimenNum: 1 …}

And it will just list the methods you have in the object and not use them:

{…mutate: [function: mutate]…}

I hope this helps a little bit! But if you are done at this point then cool. Just be sure to help me out, LOL!