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


#1




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 "
        else    
                redactedString += word + " "
    end
end
              puts redactedString


#2

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