Redacted 6/6 not getting output 'REDACTED'


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 "
    print wrd  + " "


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


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