Project: Mysterious Organism

Hi all! I’ve been doing the Mysterious Organism project and now I’m stuck with the step 3, I understand that .mutate() should return a new array with the same dna but with just one different base, I am having problems with the method, when I try to run .mutate() the console log me that isn’t a function, also I can’t figure out how can I make sure that the new dna’s base won’t be the same to the original array.

Some to help me plssss
Here 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 stand of DNA containing 15 bases
const mockUpStrand = () => {
  const newStrand = []
  for (let i = 0; i < 15; i++) {
  return newStrand


//let pAequor = {};
const pAequorFactory = (specimenNum, newStrand) => {
    const pAequor = {
    specimenNum: specimenNum,
    dna: newStrand,
    mutate() {
      // Return a mutated dna
      let bases = this.dna;
      const random = Math.floor(Math.random() * bases.length)
      let base = returnRandBase()
      if (bases[random] != base) {
        return bases.splice(random, 1, base)
  return pAequor

let organism = pAequorFactory(1, mockUpStrand())
1 Like

In order for mutate() to return a valid mutation, it will need a validation loop that repeats until the two bases do not match.

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