L4.5 incorrect instructions


#1

The instructions to this doesn't make sense please reword them so that you can have the outcome you want:

Add an if/else statement inside your .each.

If the current word equals the word to be redacted, then print "REDACTED " with that extra space.
Otherwise (else), print word + " ".
The extra space in both cases prevents the words from running together.

It should be the other way around so that the program looks just like the initial program example.

puts "Text "
text = gets.chomp
puts "Redact "
redact = gets.chomp
words = text.split(" ")

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


#2

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