Mysterious Organism Challenge Project (JavaScript)

Hi everyone! I decided to do the Project Extensions… :no_mouth: …second one was tough, but I got through it! So yeah Task 9.1 and 9.2 are included. Have a look if you’re interested :slight_smile:

Challenge Project: Mysterious Organism | JavaScript Workspace | Codecademy

Ha! Love that you count how many didn’t make it… :heart_eyes: :laughing:

Did spot a little mistake in your complementStrand() method I think. Have a look; think you’ll see it right away :slight_smile:

And I actually managed to wrestle through 9.2! So yeah have a look if you’re interested :nerd_face:

1 Like

You are right, I mess up by duplicating A to T :smile: I’ll check your solutions to 9.2. To be honest, I had no idea how to start that part.

Bingo! :clap: I had some idea… made me think of the mutual followers exercise we encountered in the course. With the nested for-loops. But yeah this was a tough one!

Feel free to ask for clarification if you want :smile:

const bobsFollowers = ['Alex', 'David', 'Andre', 'Maurice'];
const tinasFollowers = ['Angelique', 'Andre', 'Maurice'];
const mutualFollowers = [];

for (let b = 0; b < bobsFollowers.length; b++) {
  for (let t = 0; t < tinasFollowers.length; t++) {
    if (bobsFollowers[b] === tinasFollowers[t]) {


Hey guys here is my solution. Feedback will be appreciated.

GitHub repository link

Attaching my solution on GitHub. This project was quite challenging for me because objects are the most complicated topic. Glad to get some new knowledge during this process.

Hope to get a review from someone more(or even less) experienced!

I like this project.
Here’s my solution.
(first time using gist)

Hello, this is my solution. If there’s anything that could be improved, please let me know! Codecademy export · GitHub

Hi all,
And here is my Gist for this project:

It was quite challenging, took me some time, but in the end I managed to do everything without the hints!

I would really appreciate if you could have a look and tell me where I can improve my code!

Thank you,

Hi everyone,
here’s my gist for this project.
It was quite challenging for me I must admit so I would really appreciate your help to see how I could improve this.
Thanks yall

Link to my solution for this project

Would definitely say the thing that made this project a little tricky is the names and the instructions were somewhat unclear in the first few steps. I figured it out though. Didn’t do the bonus portion though may come back to that in a bit.

My commenting could be much more thorough in this one but I’m happy with the code. Not to toot my own horn but I thought using a do while to check that the mutated base was actually different was pretty elegant.

// Returns a random DNA base
const returnRandBase = () => {
  const dnaBases = ['A', 'T', 'C', 'G']
  return dnaBases[Math.floor(Math.random() * 4)] 

// Returns a random single strand of DNA containing 15 bases
const mockUpStrand = () => {
  const newStrand = []
  for (let i = 0; i < 15; i++) {
  return newStrand

// create a pAequor simulation object
const pAequorFactory = (specimenNum, dna) => {
  return {
    mutate() {
      rndNo = Math.floor(Math.random() * 15);
      const oldBase = this.dna[rndNo];
      let newBase = '';
      do {
        newBase = returnRandBase();
        // console.log(`oldBase: ${oldBase}, newBase: ${newBase}`);
      } while (newBase === oldBase);
      this.dna[rndNo] = newBase;
      return this.dna;
    compareDNA(pAequor) {
      // console.log(this.dna);
      // console.log(pAequor.dna);
      const sharedBases =, index) => {
        if (base === pAequor.dna[index]) {
          return 1;
        } else {
          return 0;
      console.log(`Specimine #${this.specimenNum} and #${pAequor.specimenNum} share ${((sharedBases.reduce((currentValue, accumulator) => currentValue + accumulator)/15)*100).toFixed(2)}% of their DNA.`);
    willLikelySurvive() {
      let C = 0;
      let G = 0;
      for (const base of this.dna) {
        switch (base) {
          case 'C':
          case 'G':
      // console.log(`% of C: ${(C/15).toFixed(1)*100} - % of G: ${(G/15).toFixed(1)*100}`);
      if ((C/15) >= 0.6 || (G/15) >=0.6) {
        return true;
      } else {
        return false;
      return false;

const samples = [
  pAequorFactory(0, [ 'A', 'G', 'G', 'A', 'C', 'G', 'G', 'A', 'C', 'T', 'A', 'A', 'A', 'T', 'T' ]),
  pAequorFactory(1, [ 'G', 'G', 'T', 'G', 'G', 'A', 'G', 'G', 'G', 'C', 'C', 'G', 'A', 'G', 'T' ]),
  pAequorFactory(2, [ 'T', 'T', 'T', 'T', 'C', 'A', 'G', 'C', 'T', 'T', 'G', 'T', 'T', 'T', 'G' ]),
  pAequorFactory(3, [ 'A', 'G', 'G', 'T', 'T', 'C', 'A', 'T', 'A', 'C', 'G', 'C', 'T', 'T', 'G' ]),
  pAequorFactory(4, [ 'C', 'C', 'T', 'A', 'C', 'T', 'C', 'C', 'G', 'A', 'C', 'C', 'T', 'C', 'C' ]),
  pAequorFactory(5, [ 'G', 'T', 'C', 'T', 'A', 'C', 'A', 'A', 'T', 'A', 'G', 'T', 'C', 'A', 'A' ])

console.log('----- Start of fixed samples tests -----');
// check if any of the manually generated samples will survive
samples.forEach(sample => console.log(`spacimen ${sample.specimenNum} likely survive: ${sample.willLikelySurvive()}`));
console.log(`sample 5's dna
console.log(`sample 5 mutated

const genPAequai = (log = false) => {
  const pAequai = [];
  for (let i = 0; i < 30; i++){
    pAequai.push(pAequorFactory(i, mockUpStrand()));
  // if log parameter is set to true log the array to console
  if (log) console.log(pAequai);
  return pAequai;

console.log('----- Start of randomly generated samples -----');
// generate array of pAequor samples
const pAequai = genPAequai();


// pAequai.forEach(pAequor => console.log(pAequor.dna));

I have included my solution here.
Let me know if you have questions or ideas to improve.

This is how I solved it.

If there’s anything that could be improved, please let me know!

Hello everyone,
I need review for my solution to the exercice.
Please let me now if you have any suggestion or appreciation !

Good days to everyone