0
Random Letter Checker
I can pass 1, 3, & 4 tests for both ways. There is something I am missing because they both will not output āDeja Vuā. What am I overlooking? Way#1 #test 1, 3, 4 passed def repeating_letters?(str) repeating_letters = gets seen = [str] str.each_char do |letter| if seen.include?(letter) return "Deja Vu" else return "Unique" end end end puts repeating_letters?("a..z") Way#2 #test 1, 3, 4 passed repeating_letters = gets def repeating_letters(str) for i in ('a'..'z') if str.count(i) > 1 return "Deja Vu" else return "Unique" end end end puts repeating_letters("a".."z")
1 Answer
0
In both ways. You only test first letter, because you instantly return after as soon as the loop starts. Place return "Unique" out of the for loop and remove else statement.