4/6. Redacted!


#1

Hi there. Could someone please help me solve this problem? I do not understand what is the problem with my code. I have tried refreshing the browser and looking at other discussions similar to this. they have the same code but mine does not work. Here is my code:

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 word + " "
  else
    print "REDACTED "
  end
end

This is what it says:

Oops, try again. It looks like you didn't print each word from the user's text to the console.


#2

In this lesson you just have to print each word it finds nothing else.so you don't need any if else condition


#3

So like this right?

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

words = text.split(" ")

words.each do |word|
end

#4

It still doesn't work


#5

Your last attempt was almost correct, you now have to print each word found in the words array.

words.each do |word|
print word
end


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.