Code works, but I get an error


#1




My code works, but an error pops up that says "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!)." But, that's what happened. It works, but won't let me pass. Thing is, I "passed" the exercise a couple times without the code actually working so I kept working at it. But now that it's working and redacting the words, it's saying my code is wrong.


puts "Your text here:"
text = gets.chomp

puts "What to redact?"
redact = gets.chomp

words = text.split(" ")

words.each do |words|
    if words == redact 
        print "REDACTED"
    else
        print words + " "
end
end


#2

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