4. Redacted


#1


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


puts "What is the text? "
text = gets.chomp
puts "What do you redact? "
redact = gets.chomp

words = text.split(" ")

words.each do |word|
    if word != text
    print word + ""
    else
    print "REDACTED "
    end
end


#2

Your comparison in the if statement is incorrect.
You were to check if the input stored in the array 'words' is equal to the redact var.
What you did is to check if 'word' iterator is (not)equal to the text var (complete input with white spaces).


#3

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