Exercise 4 of 6 in Redacted!


#1

On exercise 4 of 6 in Redacted at : https://www.codecademy.com/en/courses/ruby-beginner-en-mzrZ6/0/4?curriculum_id=5059f8619189a5000201fbcb
My Code is:

puts "Text to search through: "
text = gets.chomp
puts "Word to redact: "
redact = gets.chomp

words = text.split(" ")
words.each do |word|
if word = redact
print "REDACTED "
else
print word + " "
end
end

What am I coding wrong here to get this error message:
Oops, try again. It looks like you didn't print each word from the user's text to the console.


#2

here this worked for me:

puts "Text to search through: "
text = gets.chomp
puts "Word to redact: "
redact = gets.chomp

words = text.split(" ")

words.each do |word|
print word
end
you should not have your if/else statement just yet

hope this helps


#3

This is exactly what I have... but I'm still getting the "Oops, try again. It looks like you didn't print each word from the user's text to the console" message.


#4

U got some problem with == and =. = is not equals operation. Check 8 line in your code.
And actually perfect to use word**s** in foreach cycle (7 line).
like words.each do |words|


#5

If I'm not mistaken, I believe your issue is as I state below. I don't think it has anything to do with |word|
In your line of code (line 8), you're setting word = to redact, you're not actually checking to see if the two words are equivalent. The correct code should be:

if word == redact
...

Let me know if this resolves your issue, if not I'll manually try and figure it out.


#6

you're right that actually worked i believe it probably was too early for the if statement.

Thank you