Challenge Project: Mysterious Organism: Object Method keeps saying not defined at object

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-javascript-syntax-part-ii/modules/fecp-challenge-project-mysterious-organism/projects/mysterious-organism

Exercise 4

What am i doing wrong ?

my mutate() method in my pAequorFactory is coming up with an error "ReferenceError: mutate is not defined at Object."

Here is my code:

const pAequorFactory = (num, arr) =>{
return{
specimenNun: num,
dna: arr,
mutate(){
const pAequor = this.dna + returnRandBase;
},
}
};

Any suggestions and advice would be appreciated :slight_smile:

The comma after the mutate function does not belong there because mutate is the last thing in the object.
Also, you need to redo the mutate function to change the value of this.dna (or something like that)
(For example, the code for changing the first DNA base would be to a 'T' would be this.dna[0] = 'T';
but you’d write a much more complicated version for the project.)

Note that returnRandBase should probably be some kind of function, not a variable you add to another variable.

I tested your code (as in what was given above, with some of the corrections already mentioned):

let returnRandBase = ['A']; const pAequorFactory = (num, arr) =>{ return{ specimenNun: num, dna: arr, mutate(){ const pAequor = this.dna + returnRandBase; }, } }; let pAq12 = pAequorFactory(12, ['A', 'T', 'G']); console.log(pAq12.dna); console.log(pAq12.specimenNun); pAq12.mutate(); console.log(pAq12.dna);

HI,

Thank you very much for your help, I’m just having difficulties actually understanding what to do on exercise 4.

regards :slight_smile:

The idea is that the mutate function should change the contents of the array this.dna
by randomly selecting one of the indices of that array and then changing it to something randomly selected from 'A', 'T', 'C', 'G' (and ideally what is at that index afterward would be different than what it was before).

when you mean selected from ‘A’, ‘T’, ‘C’, ‘G’ do you mean the array from the returnRandBase function?

Yes.
You would use the returnRandBase function to select one of those.