Redacted part 5 help!?! Confused


#1

Okay, I'm really confused on this part.

Below is my code. but the error message I'm getting is:

"OOPS, try again. Make sure to print each word from the user's text to the console unless that word is the word to be redacted; if it is, print REDACTED (all caps!).

So what am I missing/doing wrong?


puts "Write your text here"
text=gets.chomp
puts "Redact something"
redact=gets.chomp
words = text.split(" ")
words.each do |words|
    if words == redact
        print "REDACTED "
    else
        print words = " "
    end
end


#2

its only supposed to be "words" once then its only "word" see:

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

hope this helps


#3

Ahhh, so simple! That worked.

Thank you so much for your help!


#4

print "enter strings"
text=(gets.chomp).split(" ")
print "word to be redact "
redact=(gets.chomp)
text.each {|holder|
if holder == redact
print "REDACTED "
else print holder + " "
end}


#5

try this:

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