Hello,
Iβve been making a start on the mysterious organism project and have hit a wall. When I try to test the function it prints mutate: [function:mutate]
Iβve copied the code below as well as what the console prints.
Any help would be much appreciated, I cant seem to see the error!!
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++) {
newStrand.push(returnRandBase())
}
return this.dna
}
const pAequorFactory = (num, arrayDnaBase) => {
return {
specimenNum: num,
dna: arrayDnaBase,
mutate() {
let randomBase = returnRandBase();
let randomIndex = Math.floor(Math.random() * 15);
//the while loop ensures that the random generation will repeat until it comes up with a unique iteration
while (this.dna[randomIndex] !== randomBase) {
this.dna[randomIndex] = returnRandBase();
}
return this.dna;
}
}
};
const pAequor = [ βTβ, βCβ, βGβ, βTβ, βAβ, βTβ, βAβ, βCβ, βTβ, βCβ, βCβ, βCβ, βGβ, βCβ, βGβ ];
console.log(pAequorFactory(1,pAequor));
WHAT THE CONSOLE PRINTS
{ specimenNum: 1,
dna: [ βTβ, βCβ, βGβ, βTβ, βAβ, βTβ, βAβ, βCβ, βTβ, βCβ, βCβ, βCβ, βGβ, βCβ, βGβ ],
mutate: [Function: mutate] }