From the course: Learning Functional Programming with JavaScript ES6+

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Anagrams

Solution: Anagrams - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript ES6+

Start my 1-month free trial

Solution: Anagrams

(upbeat music) - [Instructor] So I'm going to show you how I solved this find anagrams challenge. The way that I thought about it is this. When we have two words that are anagrams, that means that they have the exact same count of the exact same letters, but in different orders. So if order doesn't matter, then it might make sense for us to express our words like this. As an object that contains each of the letters that the word contains, with a count of how many letters it has. So for the word cinema for example, it would look like this we have one c, one i, one n, one e, one m and one a. We could then do the same with all of the other words and check to see if they have the same sort of signature, the same count of each of their letters. So for instance if we formed this same kind of object with the other words, iceman and anemic which are anagrams of cinema we would get two objects where all of the properties would be equal. Now those of you who completed the last challenge might…

Contents