Hamburg, Germany by By Rob Bye 2016

JavaScript — Comparing string letters. Freecodecamp Bonfire: Mutations Solution

Marc M
1 min readNov 20, 2016

Instructions:

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.

The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y".

Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".

Here is a helpful link:

Step: 1

  • Convert all letters to lowercase, as it will be easier to compare.

Step: 2

  • Convert strings into arrays of characters, so that we can use a loop to iterate through the arrays.

Step: 3

  • Setting up our loop: Use indexOf() to check if the letter of the second word is on the first.

--

--

Marc M

Front End Developer at Perth Bizweb, passionate about JavaScript and Functional Programming.