What is wrong with my Code?


#1



puts "Enter your text:"
text = gets.chomp
puts "Text to Replace:"
redact = gets.chomp
words = text.split(" ")
words.each do |word|
if word = redact
    print "REDACTED "
else
    print word + " "
end
end


#2

You put the assignment operator ' = ' instead of equals ' == '.

it should be if word == redact


#3

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