Redacted 5/6 not printing all words


<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

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!).

I’ve done this, the output looks correct to me, however I cannot pass this.


What is the text that you would like to search
abc def ghi jkl
What is the string you would like redacted
REDACTED def ghi jkl


puts "What is the text that you would like to search"
text = gets.chomp
puts "What is the string you would like redacted"
redacted = gets.chomp

words = text.split(" ")

words.each do |word|
    word == redacted
    print "REDACTED "
    print word + " "


It looks here to be a problem on Code Academy’s end with variable naming. For anyone who finds this in the future, change

redacted = gets.chomp


redact = gets.chomp

and all of the following uses of that variable. You will then be able to pass.


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