I need help on redacted part 5. please help me!


#1

Please help me i am so confused.

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

. puts "please enter text"
text = gets.chomp
puts "please type a word to redact"
redact = gets.chomp
words = text.split ("")
words.each do |word|
print word
if word == words
print "REDACTED "
else
print word+ " "
end
end

what am i doing wrong please help me.

`


#2

You are having word than words which you're trying to redact. And your if statement is faulty.

See below:

text = gets.chomp
puts text
redact = gets.chomp
puts redact

words = text.split(" ")

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

#3

Something is wrong with the codecademy ruby interpreter:

puts "Write your text here: "
text = gets.chomp
puts "Write a word so we can redact it: "
redact = gets.chomp

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

Execution:
Write your text here:
d
Write a word so we can redact it:
d
adsl ["adsl"]


#4

Lol! I don't think so.

It should be

You want to do words in each words and not word in each words.

Hope this helps! :slight_smile:


#5

It doesn't matter whats inside the | | (or), its just a placeholder. All that matters is you use the same place holder within the ".each" body. It could be "x" if you wanted

words.each do |x|
#argument on x
end

it could be word, words, x, y, z, suckmydick, it don't matter


#6

There is not space in this line
words = text.split ("") => words = text.split (" ") since you are telling the program to find spaces.

And
if word == words => if word==redact