Redacted 5 Control Flow (Help! I've tried everything)


#1



https://www.codecademy.com/courses/ruby-beginner-en-mzrZ6/0/5?curriculum_id=5059f8619189a5000201fbcb


When I press save and submit it says, "Oops, try again. Make sure to print each word from the user's text to the console unless that word is the word to be redacted; if it is, print REDACTED (all caps!)."


puts "Insert Text: "
text = gets.chomp
puts "Please redact: "
redact = gets.chomp

words = text.split (" ")

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


#2
plural.each do |singular|

as in,

words.each do |word|

#3

Still didn't work..

puts "Insert Text: "
text = gets.chomp
puts "Please redact: "
redact = gets.chomp

words = text.split (" ")

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


#4

Change this one to word as well.


#5

Tried that too :confused: still no luck.

Here is what my code looks like based on the updates you provided. Is there anything else you see as to why this might still be failing?

puts "Insert Text: "
text = gets.chomp
puts "Please redact: "
redact = gets.chomp

words = text.split (" ")

words.each do |word|

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


#6

The space character after split may be a problem.


#7

Still didn't work. Any other ideas that I can try?


#8

Perhaps try refreshing the page. I tried your code and passed.


#10

Try using a different browser?


#11

Your code is right, try to reset browser. I've checked on Chrome using Windows 7.


#12

It is not right to use here singular word, as the variable is declared in plural. Code doesn't have two variables 'words' and 'word'.


#13

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