Today’s basic Javascript algorithm is about Mutations. You will build a function that will output true or false. This will be based on an input which will be an array. The array has two strings. The goal is to make sure that every letter (even repeated characters) in the second string exist in the first string.

The book of mystery identity.

The two strings don’t have to be the same words. If an array has the two strings “monkey” and “money”, the function will return true because deep inside the soul of the word “monkey”, there is the word “money”. Does this mean all monkeys have money? No. It means…. well the function works.

Sometimes words have a hard time finding out who they are. They seek to find as many words within themselves. It is as if the word “monkey” looked into a mirror and instead of finding the word “monkey”, it also found the words “key”, “money”, “monk”, “one”.

Imagine looking into a mirror and only seeing small eyes and a big nose.

Not all words are as lucky as the word “monkey”. One unlucky word is the word “bag”. Now the second string doesn’t have to be an actual word but come on, “ba” and “ag” don’t sound like exciting words. “Ba” is just the sound tired sheep make and “ag” is the sound well … more tired sheep make.

For this function let’s imagine one of the inputs is an array that holds two strings, “hello” and “heefs” (yes, heefs).

One day this freckled girl will grow up to be an elegant old man with a beard, luscious long hair and fuzzy smily face shoes.

If you compared the two words, they look like two different words. That is because they are (I congratulate your eyes). The next step is to know if every letter in “heefs” (the e’s must also appear twice) appear in “hello”.

Mr. Heefs is confused.

The word “hello” is is broken down into individual letters and each letter. The only way to know if Mr. Heefs fits in is if every letter in “heefs” is in “hello”, is if he sees himself in the word. Like a mirror, he doesn’t see himself. The second e is missing and there isn’t an f and where is sweet letter s. He stands in confusion with a giant bold question mark written in 45px helvetica bold.

But what if, instead of “heefs” that vocabulary is another “hello”?

If you have noticed, Mr. Heefs is now Mr. Hello
Hello and Hello, the bearded man now shows smile behind that vast, wild, and untamed beard.

Since each letter in “hello” exists inside of … “hello”. The function will return true. Because not all of the letters in “heefs” didn’t exist in the word “hello”, the function would have returned false. Now when the Mr. Hello (previously Mr. Heefs) looks into that mirror, he can finally see himself in the word.

Oh and by the way, the author of the book “Who are you? Who am I?” in the beginning of this post is in fact Mr. Heefs. The book will be soon released to your local imaginary bookstore nearest to your thoughts.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.