Redacted 6/6 not getting output 'REDACTED'


#1

This code dont give output ‘REDACTED’. It outputs only the same input text without reacted text

puts "Enter some text: "
text = gets.chomp

puts "Enter words to redact: "
redact = gets.chomp

words = text.split(" ")

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

#2

Please remember to include a link to the exercise when posting a question in Q&A. Thanks.

How are you entering the words to redact? As a phrase? A comma separated list? An array?

The above implies there is only one word to redact, not a list of words.

    if redact.includes? wrd

#3

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