Control Flow Step 5/6


#1

I got a "way to go!" statement to continue... however I feel like the code didn't do what the exercise asked for? My code is the following:

puts "Text to search through"
text = gets.chomp
puts "Word to redact"
redact = gets.chomp

words = text.split(",")
words.each do |word|
if word == redact
print " REDACTED "
else
print word + " "
end

When I run this, I get a clear on the task but the console will do this:

Text to search through
Hello there
Word to redact
there
Hello there ["Hello there"]

It doesn't redact anything. What have I done wrong here?


#2
words = text.split(",")

You're splitting your input on the comma, so if you want it to work you either need to split on the space or simply give your input separated by commas.