Control Flow Know-how 5/6 ACCEPTED STILL CONFUSED


#1

If anyone could please help me with some sort of syntax error. While this code was accepted, it isn't running properly. None of the words i type are printed to the screen, REDACTED is printed once for every letter i type, then followed by the individual letters comprising the texts. i feel it has something to do with my .each loop, specifically words.each do |word|... any thoughts?

puts "Please define texts."
text = gets.chomp

puts "word to redact"
redact = gets.chomp

words = text.split ("")

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


#2

This post was flagged by the community and is temporarily hidden.


#3

Whatever you define between (" ") quotes will be the split point of turning String into array. For instance if you leave (" ") space like this, means that it would split "I am Dhillon and i'm your friend." into an array like this ["I", "am", "Dhillon"....so on because it recognized blank space in your quotes as an array splitter. You can replace space with other letters, symbols or numbers etc. to use as splitter accordingly.