Mysterious Organism Challenge Project (JavaScript)

Here is my solution to the mysterious organism project:

This and the credit card checker project definitely stretched my brain in many ways. Was tough, and I definitely needed help haha but thanks to all who have come before with their tips.

All was well until I hit step 5 and I got lost doing the comparing. It’s translating the concept into code that killed.

Do the rest of you just write it out, or do you draw a logic tree and then translate it into code? I would love to get insight into your process when the solution and steps aren’t obvious. I didn’t know how to name the currently unnamed samples to compare them. This.SpecimenNum but then what would the second one be? 2?

I would love any insights you have into it.

Here is my code before that.

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++) {
  return newStrand

const pAequorFactory = (specimenNum, dna) => {
  return {
    specimenNum: specimenNum,
   dna: dna,
   mutate () {
 specimenNum.filter(dna => dna !== dna);
  //console.log(pAequorFactory(2, dna.mutate())); 
 compareDNA() {
pAequorFactory(2, dna.mutate()
console.log(`Specimen #1 and specimen #2 have: ${compareDNA} in common.`)


//console.log(pAequorFactory(2, dna.mutate()));

Check out my code for the Mysterious Organism Challenge. It was challenging but I made it through!

My code for the Mysterious Organisms Project

I usually try to start with what I want the result to look like, and work backward from there …

What should I return?
A percentage or a proportion.

How do I get it?
The instructions say that the percentage similar is based on if they have the same letter in the same position.

How can I find that percentage?
I can count haw many are the same (which would be a number) and divide by the total number of stuff (the length of the array). Maybe I’ll need to multiply by 100 to change it from a decimal to a percentage.

How do I do that counting?
Iterate through both arrays, check if they have the same thing at each index. If they do, add one to a counter number variable?

How can I code that?
Set up a counter variable, then a for-loop that iterates by the index (from 0 to less than the length).
with an if-statement inside the for-loop.

here is my code for Mysterious Organism

My solution can be found at the GitHub link below. I believe it all works, probably not very elegant…but I am SO excited lol to actually have it there and tested and working. I also did the bonus function.
My Project

And I would love comments.

Modify the results slightly to make them look beautiful.
:smiley: :smiley: :smiley:

Challenge Project: Mysterious Organism

Hey Everyone!

Here’s my solution for “Mysterious Organism”:

Hi to everyone! This is my solution of Mysterious Organism Project. I`ll appreciate any comments.

Hi everyone! Here’s my resolution of the project: codecademy/main.js at main · NilsonCesar/codecademy · GitHub

With the complementary chalenges :wink:

Hello everyone, here is my attempt , finally started getting the hang of this.

Thanks for posting your solution. All of your steps were basically the same as mine, but your code was more concise, so you helped me to slim down my approach.

For example, your line 41,

const cOrG = this.dna.filter(el => el === "C" || el === "G");

I like this more than the for loop that I originally used.

1 Like

thank you, however this line in particular I copied from the solution provided in this thread (just to put credit where its due), but yes that line is better than the one I had before

Ok, cool. I must not have looked at at that one.

Hey everyone, here is my solution for this project. I spent a lot longer on this than I expected but I’m glad I was able to work it out in the end!

Another good challenge. I tend to rely on for loops and indexes which I find much easier to use when manipulating arrays. Maybe I’ll figure out how to refactor it using Array methods. Any feedback or questions are quite welcome.

Mysterious-Organism project

PS If someone could explain how to have my code display in this window, that would be cool!

Another project down! Ill link my code below feel free to leave a comment or question thanks in advance.

code:mystery-organism-starter/main.js at master · Dave2188/mystery-organism-starter · GitHub

This one was challenging after not using javascript for quite some time but I was able to stay patient and get it done.
here is my work at GitHub: Ali Salim mystery-organism-starter