Redacted 6/6. Can I make it shorter?!?!


Below is my code, it is working fine. The code includes all the extra questions properties, but I would like to know if I can still simplify the code, to make it more efficient.

     puts "Text to go through: "
     text = gets.chomp.downcase

    puts "Word to redact: "
    redact = gets.chomp.downcase

        redactedString = " "

    words = text.split(" ")
    redactedWords = redact.split(" ")

words.each do |word|
        if redactedWords.include? word
                redactedString += "REDACTED "
                redactedString += word + " "
              puts redactedString


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