-
-
Save codecademydev/9ee7eb1551413e97a5939f94c545bd0c to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} | |
//console.log(returnRandBase()) | |
const pAequorFactory = (num, dnabase) => { | |
return { | |
specimenNum: num, | |
dna: dnabase, | |
mutate() { | |
const randIndex = Math.floor(Math.random() * this.dna.length); | |
//i like to console.log the value of randIndex at this point? | |
console.log(randIndex) | |
let newBase = returnRandBase(); | |
while (this.dna[randIndex] === newBase) { | |
newBase = returnRandBase(); | |
} | |
this.dna[randIndex] = newBase; | |
return this.dna; | |
} | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment