Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created Mar 16, 2021
Embed
What would you like to do?
Codecademy export
// 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
}
const pAequorFactor = (num, basesArray) => {
return {
SpecimenNum:num,
dna:basesArray,
mutate () {
let currentBase = returnRandBase();
let generatedBase;
let newStrand = [];
if (currentBase === "A") {
generatedBase = bases.slice(1).Math.floor(Math.random(3))
} else if(currentBase === "T") {
generatedBase = ['A', 'C', 'G'].Math.floor(Math.random(3))
} else {
generatedBase = ['A', 'T', 'C'].Math.floor(Math.random(3));
}
for(let i = 0;i < 15; i++) {
this.dna = newStrand.push(generatedBase);
}
return this.dna;
}
}
}
console.log(pAequorFactor.mutate());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment