Hello. I am attempting to write this code can take multiple, seperate words to react.
As well as how to safe the redracted string as a variable instead of printing but I'm on the former part first.
At the moment when I type it in, this is what happens.
Hello there good sir
What is the redact?
Hello Hello there there REDACTED good sir REDACTED ["Hello", "there", "good", "sir"]
And if I type 3 words that would be redacted instead of two, it prints everything three times excluding one fo the redacted words as REDACTED. Not sure why. Thank you for any help.
Replace this line with your code. puts "Please input" text = gets.chomp puts "What is the redact?" redact= gets.chomp words= text.split (" ") all_redacts= redact.split (" ") words.each do |x| all_redacts.each do |y| if x == y print "REDACTED " else print x + " " end end end