Mysterious Organism

Hello! I am currently working on the mysterious Organism project and I am having some trouble comprehending step #4. From what I have read through the articles, and what I understood so far with mutate method is that it changes the current base, So far that is all I have gotten. I have looked through the forums and tried my own code but just can’t get over this though hump would anyone have advice or a different perspective on this problem. The question reads as follows:
" Your team wants you to simulate P. aequor‘s high rate of mutation (change in its DNA).

To simulate a mutation, in pAequorFactory()‘s returned object, add the method .mutate().

.mutate() is responsible for randomly selecting a base in the object’s dna property and changing the current base to a different base. Then .mutate() will return the object’s dna.

For example, if the randomly selected base is the 1st base and it is 'A', the base must be changed to 'T', 'C', or 'G'. But it cannot be 'A' again."

This is my code:

/ 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++) {
    newStrand.push(returnRandBase());
  }
  return newStrand;
};

const pAequorFactory = (num, arr) => {
  return {
    specimenNum: num,
    dna: arr,
    mutate()  {
 let randomIndex = Math.floor(Math.random()*15);
    }
  }
};

//  console.log(pAequorFactory(1, mockUpStrand()))

I would rather understand what is going on then just copy, paste, and move on. lol!

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