5 Redacated! control flow know how


#1

puts "please enter some personal text"
text = gets.chomp

puts "please enter info to redact"
redact = gets.chomp

words = text.split ("")
words.each do |word|
if word == redact
print "REDACT"
else
print word + ""
end
end
I am so confused why this isnt working


#2

Should read letters = text.split(""), if, that is, we were splitting between letters, such as that line does. To split between words, we use " " owing that the space character is a typical word separator.

words = text.split(" ")