I'm trying to get this to pass spec to verify if an argument is an anagram of another word, but it's just not happening.
- I can get the string (starting with just one sting word) into an array, and whether it's one or multiple words,
- It then iterates through the array over each word.
- Using the If statement to compare if the sorted object is equal to the sorted argument.
Applied .join, since it came out one letter at a time in irb, but it's still not happening, with or without .join.
class String define_method(:anagrams) do |check_word| words = self.downcase check_word = check_word.downcase words_array = words.split(" ") words_array.each do |word| if (word.chars.sort) == (check_word.chars.sort) true else false end end end end
Any ideas why it's broken?