5 control flow know how


#1

what am i doing wrong here?
puts "Search for a word"
text=gets.chomp

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

words=text.split(" ")

words.each do |word|
print word
if word==redact
print "REDACTED "
else
print word + " "
end
end


#2

I was just doing this exercise, I think you have to remove the "print word" directly following the if statement. in other words you should have your if statement then what you want it to print, then else statement, then what you want it to print end end.

words.each do |word|

if word==redact
print "REDACTED "
else
print word + " "
end
end